VEX: Is there a short way to specify return type of point()?

   239   3   0
User Avatar
Member
447 posts
Joined: Aug. 2019
Offline
In VEX we can't write this:

setpointattrib(0, name, @ptnum, point(1, name, @ptnum));

Because VEX doesn't know what the return type of point() is.

I know I can do this instead:

vector value = point(1, name, @ptnum);
setpointattrib(0, name, @ptnum, value);

But I wonder is there a shorter way without declaring an extra variable?
User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
Yes, we can

setpointattrib(0, name, @ptnum, vector(point(1, name, @ptnum)));
User Avatar
Member
447 posts
Joined: Aug. 2019
Offline
Cool!

I've got another confusion tho: Is there any difference between

vector(xxx)

and

(vector)xxx

?
User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
There really is a difference between them, the first form of vector() is essentially a constructor for creating an object of type vector, the second entry of the form (vector) performs an implicit type cast to a vector, which will not work in this expression since we need to explicitly indicate what type it returns point function.
  • Quick Links