Jump to content

Is it correct to always set the attribute type in vex wrangle code ?


Recommended Posts

Hello, friends! I`ve got some issues when started coding in vex with the default float type attribute creation, so i got a habit to always set the attribute type, even in calculations, to prevent the possibility of attribute type errors.

Like this for example:

v@direction = v@initial_position - v@P;

It works fine, and i am really comfortable with it,  but I wonder is it correct in the meaning of

1) Good programming style. 

2) VEX language work under the hood - maybe VEX is re-declaring the attributes again, when they are used in this way.

Thank you!

Link to comment
Share on other sites

  • 1 year later...

It's not essential in the same wrangle node. But if you declare an attribute in wrangle node and assign it to some other attribute in another wrangle node, it becomes essential. Like you declare a vector attribute like this :

v@x = set(1,2,4);

And if in another wrangle node you assign it to another new vector attribute :

v@y = @x;

In geometry spreadsheet, you will get only first element of attribute x in all elements of y :

y[0] = 1

y[1] = 1

y[2] = 1

This happens as it considers @x to float.

To resolve this... You shall have to declare data type again :

v@y = v@x;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...