JackDunaway Posted March 15, 2012 Report 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
Popular Post Darin Posted March 15, 2012 Popular Post Report 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
vugie Posted March 15, 2012 Report 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
asbo Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 7:59 AM, vugie said: s?t:f - select Trivia: this is referred to as a ternary operation. Quote
crelf Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 7:59 AM, vugie said: s?t:f - select On 3/15/2012 at 2:41 PM, asbo said: Trivia: this is referred to as a ternary operation. More trivia: ...and is the same format for a Boolean selection in TestStand expressions. Quote
asbo Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 3:42 PM, crelf said: 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
JackDunaway Posted March 15, 2012 Author Report Posted March 15, 2012 On 3/15/2012 at 5:56 AM, Darin said: &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? ) On 3/15/2012 at 7:59 AM, vugie said: 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
crelf Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 5:05 PM, JackDunaway said: 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
asbo Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 5:31 PM, crelf said: 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
crelf Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 6:09 PM, asbo said: Ah, this is actually one I don't like. Well then you're a stupid poo bum doodie head. On 3/15/2012 at 6:09 PM, asbo said: 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). On 3/15/2012 at 6:09 PM, asbo said: 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
asbo Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 6:24 PM, crelf said: Well then you're a stupid poo bum doodie head. Elegantly put. I redact my comments. On 3/15/2012 at 6:24 PM, crelf said: 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
crelf Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 6:38 PM, asbo said: Elegantly put. I redact my comments. Damn right. I choose to stop reading your post at this point. 1 Quote
Popular Post hooovahh Posted March 15, 2012 Popular Post Report Posted March 15, 2012 On 3/15/2012 at 7:18 PM, crelf said: Damn right. I choose to stop reading your post at this point. I hate it when mom and dad fight... 4 Quote
crelf Posted March 15, 2012 Report Posted March 15, 2012 On 3/15/2012 at 7:49 PM, hooovahh said: I hate it when mom and dad fight... I call "dad". 1 Quote
jgcode Posted March 16, 2012 Report Posted March 16, 2012 This thread should be pinned. Hilarious! Quote
crelf Posted March 16, 2012 Report Posted March 16, 2012 On 3/15/2012 at 3:51 PM, asbo said: That's because TestStand expressions are modeled after text-based languages like C. PS: wikipedia page updated to include TestStand. Quote
asbo Posted March 16, 2012 Report Posted March 16, 2012 On 3/16/2012 at 5:26 PM, crelf said: 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
Aristos Queue Posted March 16, 2012 Report Posted March 16, 2012 (edited) On 3/15/2012 at 5:40 AM, JackDunaway said: 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." On 3/15/2012 at 7:59 AM, vugie said: 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. On 3/15/2012 at 7:49 PM, hooovahh said: 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
crelf Posted March 16, 2012 Report Posted March 16, 2012 On 3/16/2012 at 6:07 PM, asbo said: 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
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.