Jump to content

VEX:: User-defined functions calls problems

Recommended Posts

I don't usually meddle with functions in VEX, but today decided to give it a go since I wanted to have some functions being used by other functions.

I'm having issues calling functions inside functions. The code below for example will trigger errors.

float foo(float a, b) {
    a = clamp(a, 0, 1) ;
    return a + b ;

float bar(float a, b) {
    return foo(a+.1, b+.1) ;


And it can be "solved" in multiple ways:

If for example I comment out the clamp part it passes:

If instead I remove the +.1 from foo it works as well.

I have other examples where such simple corrections and the multiple corrections don't work or are not straightforward so what I'm after is understanding what's the main cause of this. Either I'm missing some method here ( I did try C++ style declaration / definition) or maybe there's some issue with calling a functions from a function.



Edited by probiner

Share this post

Link to post
Share on other sites
15 minutes ago, f1480187 said:

Submit a bug. Compute intermediate variables explicitly, as a workaround.

That's the issue @f1480187 I could patch here and there, but it's not clear what it is as patching on either function will do... But it's no standard.

I did file a bug report, thanks.

Share this post

Link to post
Share on other sites

I think the problem is "a + 0.1" expression used as argument of custom function called inside different custom function, and when both functions defined inside third function (wrangle). Intermediate "float a_ = a + 0.1;" solves it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now