Currently, we can make inputs to subVIs optional (or indeed recommended) and not wire them - in this case, the default value for the input terminal is used. By default, this is the default value for the type, but it can be easily changed to another value (at least for terminals you can easily set).
Since there is no "optional" type, this leads to code potentially like
If -1 is always an invalid value here, this might not be so terrible. The issue becomes more pervasive with, for example, empty strings (or string constants) when an empty string or that constant might conceivably be a valid value.
Class objects could be an additional problem, especially if a hierarchy is considered, because you might want to wire an uninitialized child object to an Init Object method, and it would fail an equality check vs the terminal type. You might then mistakenly conclude that it was already partially/fully initialized, and carry out the incorrect processing (in this exact case, probably dynamic dispatch followed by an equality check against the specific child, then calls to a static dispatch "Init Object_internal.vi" in the parent might work).
We can work around this if needed by using a boolean clustered with the value, and then checking the boolean, but this makes wiring the subVI and creating its inputs more frustrating.
I would like to see an optional terminal type that could be checked using a primitive to indicate if it was wired by the caller or not.
(Apologies for the ugly icon, and probably dubious naming)
For the draft of the proposing paper in C++ for the std::optional type, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3672.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Duplicate of https://forums.ni.com/t5/LabVIEW-Idea-Exchange/New-property-of-Method-to-indicate-if-an-input-of-a-s...