nikaragua86 Posted September 22, 2018 Share 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! Quote Link to comment Share on other sites More sharing options...
Jesper Rahlff Posted September 22, 2018 Share 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 Quote Link to comment Share on other sites More sharing options...
nikaragua86 Posted September 22, 2018 Author Share Posted September 22, 2018 Thank you very much! Quote Link to comment Share on other sites More sharing options...
fencer Posted September 22, 2018 Share 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. Quote Link to comment Share on other sites More sharing options...
nikaragua86 Posted September 22, 2018 Author Share Posted September 22, 2018 Thank you! Quote Link to comment Share on other sites More sharing options...
animatrix Posted September 22, 2018 Share 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. Quote Link to comment Share on other sites More sharing options...
nikaragua86 Posted September 24, 2018 Author Share Posted September 24, 2018 Aha, thank you. Quote Link to comment Share on other sites More sharing options...
acey195 Posted September 24, 2018 Share 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, Quote Link to comment Share on other sites More sharing options...
nikaragua86 Posted September 29, 2018 Author Share Posted September 29, 2018 Thank you! Quote Link to comment Share on other sites More sharing options...
Waqar Posted November 5, 2019 Share Posted November 5, 2019 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.