LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
Intaris

Custom default value for typedefs

Status: Declined
Adding functionality would become too difficult when using the type def in app builder.

I was just involved in a discussion about a default return value for the dequeue primitive when a different idea struck me.

 

Why can't we define a default value for typedefs.  Especially enums would benefit by having a case reserved for operations where something didn't work as expected and a default value is returned.  Being able to seperate this value from other (normally required) values would be a boon for ensuring data integrity.

 

21307i98E925E66B45E54C

 

Why can't we have the default value set to something we don't normally interpret as being valid?

5 Comments
Intaris
Proven Zealot

Queue discussion was HERE


 

RandyP
Member

Hmm... I feel pretty strongly that all base data types should maintain their default values (enums, and yes, even rings maintaining a default of 0) because of the potential for confusion otherwise.

 

In other words, any time I see a string, if I think "What's the default value?", I know right away that it's an empty string, and always will be. Default numerics are always 0. Default bools are always false. Default references are always untrustworthy =). Default clusters always hold the default values of their components.

 

This was discussed a bit in this post, as I was reminded of today by JackDunaway. I don't have a problem with his Add a Terminal that Defines Default Data for Reshape Array idea, because that has to do with applying an alternate default value to a specific function, only at the time that that instance of the function is run. (As opposed to an alternate default value getting carried along a wire).

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
AristosQueue (NI)
NI Employee (retired)

Typedefs would have problems supporting this feature. First, stripping typedefs during AppBuilder would suddenly change the behavior of your program. Second, editing the default value of the typedef would have undefined behavior for all the existing controls/constants of that typedef.

 

We discussed all these issues with typedefs when designing LV classes. Typedefs are really just names for existing types, not really creating new data types, whereas we made classes really rise to the challenge of creating a new data type, with its own default value and all the behaviors thereof. If you want this behavior, create a class of your type, not a typedef.

Intaris
Proven Zealot

Fair comments.  Especially the idea of stripping typedefs in the AppBuilder I had ot considered.  That alone is a no-go decision.

G-Money
NI Employee (retired)
Status changed to: Declined
Adding functionality would become too difficult when using the type def in app builder.