nikaragua86 9 Posted September 22, 2018 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! Share this post Link to post Share on other sites
Jesper Rahlff 97 Posted September 22, 2018 there is no downside to doing that as far as I am aware, except you have to type a few more characters. However it is looked at as extremely good practice to do so, so I would continue doing it if I were you Share this post Link to post Share on other sites
nikaragua86 9 Posted September 22, 2018 Thank you very much! Share this post Link to post Share on other sites
fencer 158 Posted September 22, 2018 Prefer not to add type for global variables like @P, @N, @v.... but if there is a custom variable like f@mysuperval, yes it must be. Share this post Link to post Share on other sites
pusat 132 Posted September 22, 2018 I only add type if the attribute is unknown to Houdini and it's not a float. Using @ for unknown attributes will declare it as a float. Share this post Link to post Share on other sites
nikaragua86 9 Posted September 24, 2018 Aha, thank you. Share this post Link to post Share on other sites
acey195 162 Posted September 24, 2018 In my opinion explicitly typing your attributes is good practice; in particular, for not accidentally using floats when you can/should use integers(if you want to check against specific numbers) if(x==6) is way better than if(x==6.0) for example, Share this post Link to post Share on other sites
Waqar 0 Posted November 5 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; Share this post Link to post Share on other sites