The ampersand and the vex... what is this about?

   1538   2   0
User Avatar
Member
14 posts
Joined: June 2021
Offline
A Houdini fetus here. After watching the various, albeit rare (kudos Horikawa), channels on HOW to use such a beast... no one explains the WHY.
Why is the ampersand so critical in parts of the Vex world? Clearly, a wnoise vex function cannot be fully utilized without accessing the ampersand feature.
I would be grateful for a deeper explanation.
User Avatar
Member
9417 posts
Joined: July 2007
Offline
if you are talking about the docs, & just means that the argument variable with & will be modified
not really sure if it's just manually put in the docs or it was automatically analyzed from the code, since in VEX all arguments are passed by reference and therefore in theory function can modify any of the arguments unless it's const

so in case of:
void  wnoise(float position, int &seed, float &f1, float &f2)

the function will not return anything directly since its void
but will modify variables used for seed, f1 and f2
which can be also thought of as it returns 3 values: seed, f1 and f2
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
14 posts
Joined: June 2021
Offline
Very helpful. Thank you.
  • Quick Links