JackDunaway Posted March 15, 2012 Report Share Posted March 15, 2012 Earlier today I was showing the LabVIEW Typecast function to a Perl developer, and I got to thinking to myself: "What does the punctuation (operators?) on the output of that function mean?" Can anyone answer the question: What does "*(type *) &x" mean? Quote Link to comment
Popular Post Darin Posted March 15, 2012 Popular Post Report Share Posted March 15, 2012 &x is the address of x (type *) is a coercion to pointer to type * is dereferencing value at x treated as type. 3 Quote Link to comment
vugie Posted March 15, 2012 Report Share Posted March 15, 2012 There are few others descriptions of terminals understandable only for text programmers (if not for C-programmers strictly): x-y*floor(x/y) - reminder r*e^(i*theta) - complex number s?t:f - select NaN - not a number Quote Link to comment
asbo Posted March 15, 2012 Report Share Posted March 15, 2012 s?t:f - select Trivia: this is referred to as a ternary operation. Quote Link to comment
crelf Posted March 15, 2012 Report Share Posted March 15, 2012 s?t:f - select Trivia: this is referred to as a ternary operation. More trivia: ...and is the same format for a Boolean selection in TestStand expressions. Quote Link to comment
asbo Posted March 15, 2012 Report Share Posted March 15, 2012 More trivia: ...and is the same format for a Boolean selection in TestStand expressions. That's because TestStand expressions are modeled after text-based languages like C. Quote Link to comment
JackDunaway Posted March 15, 2012 Author Report Share Posted March 15, 2012 &x is the address of x (type *) is a coercion to pointer to type * is dereferencing value at x treated as type. Thanks! That syntax was teetering just above my level of C syntax comprehension (rather, tolerance? ) There are few others descriptions of terminals understandable only for text programmers (if not for C-programmers strictly): x-y*floor(x/y) - reminder r*e^(i*theta) - complex number s?t:f - select NaN - not a number Another notable carry-over is the use of "[]" to signify "array". You can find this C syntax many of the primitive icons themselves, not just the terminal names. (And just for the record: generally, it makes sense to reuse these conventions in LabVIEW rather than invent new analogies. The typecast example is one of the few instances where I might consider breaking this convention, just because the syntax is confusing) Quote Link to comment
crelf Posted March 15, 2012 Report Share Posted March 15, 2012 And just for the record: generally, it makes sense to reuse these conventions in LabVIEW rather than invent new analogies. Absolutely! Another reason I like to use the OpenG comment, rather than other arbitrary free text labels. Quote Link to comment
asbo Posted March 15, 2012 Report Share Posted March 15, 2012 Absolutely! Another reason I like to use the OpenG comment, rather than other arbitrary free text labels. Ah, this is actually one I don't like. The syntactic significance of /* ... */ is moot in LabVIEW - what else could a free label be used for on the block diagram but to comment? I particularly dislike the color contrast chosen for the OpenG comment. I see no value-add except having more colors on your BD. I whole-heartedly embraced the square-bracket array notation (but rarely find cases where I think its necessary) and think that the typecast terminals are only misleading in that they use the & and * operators in a language that's almost exclusively by-value. I remember the first time I read that terminal, I got a little warm and fuzzy feeling for knowing exactly what it meant, though. Ah, C, I miss you sometimes... Quote Link to comment
crelf Posted March 15, 2012 Report Share Posted March 15, 2012 Ah, this is actually one I don't like. Well then you're a stupid poo bum doodie head. The syntactic significance of /* ... */ is moot in LabVIEW - what else could a free label be used for on the block diagram but to comment? Lots of things - like custom classes of tags that cen be read by scripting nodes (eg: run a report that scans free text labels that are a particular color or start with a particular tag to show all those "fixme" notes). I particularly dislike the color contrast chosen for the OpenG comment. I see no value-add except having more colors on your BD. It wasn't as much chosen for OpenG, it's an already accepted standard in multiple programming languages - to make it something else is unintuative. 1 Quote Link to comment
asbo Posted March 15, 2012 Report Share Posted March 15, 2012 Well then you're a stupid poo bum doodie head. Elegantly put. I redact my comments. Lots of things - like custom classes of tags that cen be read by scripting nodes (eg: run a report that scans free text labels that are a particular color or start with a particular tag to show all those "fixme" notes). It wasn't as much chosen for OpenG, it's an already accepted standard in multiple programming languages - to make it something else is unintuative. This sounds like a weak case to use scripting to dig through property nodes. Personally, sticking a "TODO:", "DEBUG:", or "FIXME:" just as easily facilitates finding these comments without requiring that the free label be of any specific format. I recognize that it is a standard, but argue that it's simply one that does not apply. Keep an eye on your svn logs, I'm going to start changing all of your comments. 2 Quote Link to comment
crelf Posted March 15, 2012 Report Share Posted March 15, 2012 Elegantly put. I redact my comments. Damn right. I choose to stop reading your post at this point. 1 Quote Link to comment
Popular Post hooovahh Posted March 15, 2012 Popular Post Report Share Posted March 15, 2012 Damn right. I choose to stop reading your post at this point. I hate it when mom and dad fight... 4 Quote Link to comment
crelf Posted March 15, 2012 Report Share Posted March 15, 2012 I hate it when mom and dad fight... I call "dad". 1 Quote Link to comment
jgcode Posted March 16, 2012 Report Share Posted March 16, 2012 This thread should be pinned. Hilarious! Quote Link to comment
crelf Posted March 16, 2012 Report Share Posted March 16, 2012 That's because TestStand expressions are modeled after text-based languages like C. PS: wikipedia page updated to include TestStand. Quote Link to comment
asbo Posted March 16, 2012 Report Share Posted March 16, 2012 PS: wikipedia page updated to include TestStand. I added some formatting and expanded it a bit. I was going to come up with an example of using completely different functions in each sub-expression, but got lazy. Quote Link to comment
Aristos Queue Posted March 16, 2012 Report Share Posted March 16, 2012 (edited) Can anyone answer the question: What does "*(type *) &x" mean? It means a LabVIEW developer momentarily forgot that his/her users were not C++ programmers, the tech writer was on vacation, and this was written so long ago that when I asked if we could change it, the answer I got was, "No, that's the label of the terminal, which means someone might be using it in scripting code, and you'll break their code if you change it now."NaN - not a number That one doesn't count. That's an IEEE standard definition of the numerical value of Not A Number. That's correct as it stands, not a C++-ism that should have been scrubbed back in the dawn of LabVIEW. I hate it when mom and dad fight... At least he's not drinking tonight. "Two beds and a coffee machine..." ** Hah! Take that stupid editor. Try to inline my media files when I don't want you to... grrr... Edited March 16, 2012 by Aristos Queue Quote Link to comment
crelf Posted March 16, 2012 Report Share Posted March 16, 2012 I added some formatting and expanded it a bit. I was going to come up with an example of using completely different functions in each sub-expression, but got lazy. Yeah, I think keeping the terms the same as the previous example works. Also, I added "()" for clarity. Quote Link to comment
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.