From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
I propose that Case Selectors should accept any type of reference, and the two cases generated are "Valid Ref" and "Invalid Ref". (This would be very similar to the current behavior of the Case Selector accepting errors with the two cases of "Error" and "No Error".)
The current behavior using "Not a Number/Path/Refnum" is very unintuitive. It requires the programmer to use Not Logic (i.e., do something if the reference is "not not valid").
I really am surprised this idea has so many kudoes. It sounds nice, but is it really necessary considering the current situation is just the use of a Not a Ref function which already exists?
Select class based on Refnum could be a much more useful idea and I would rather see that implemented over this.
Interesting. I commented on this LAVA post today, then happened across this suggestion. Aristos makes an important observation about misusing the "Not A Refnum" primative that can create a race condition in your application.
There are lots of LV power users who have kudoed this idea. I'll risk the tar and feathers and say no, this is not a good idea. I posted my response on LAVA before I saw Phillip had linked to this idea, so I'll just summarize my argument here for those that don't want to read through the entire LAVA thread.
Pretesting a reference before performing an operation on that reference is a race condition and should be discouraged. It's not just the Not A Refnum function, it's any sort of pretesting used to make execution branching decisions. Your users may never encounter the race condition, but it is there. If you're operating on a reference, attempt the operation then do a postcheck for errors.
I have a tendency to agree that this idea could promote "seemingly safe" but actually bad practices, and after AQ's warning in 2009, I actually came to realize this is probably not a good feature to add to the language. Granted, it would be acceptable and syntactically slick to execute code in the <Not a Refnum> case, but the tendency for developers to place code in the <Valid Refnum> case makes it dangerous (even my snippet to promote this Idea makes this mistake!).
I respectfully suggest this Idea be Rejected on the grounds of potentially causing more problems than the syntactical sugar is worth (and also because it complicates the case selection of class types, a much cooler and more useful Idea)