Jump to content

Has anyone experimented with operator overloading at all?


Recommended Posts

Yes, LabVIEW has operator overloading, or at least a form of it. It's what the matrix typedefs use to override various math operators, where it replaces them with a subVI.

Operator overloading, as far as I can tell, is undocumented, and not used anywhere outside the matrix typedefs. It's configured using a "NI.LV.All.OperatorInfo1" tag on the control VI, set using the private method "Tag.Set Tag".

I've attached a VI I was using to mess around with; it's supposed to create a string typedef which, when wired to a Multiply node, will replace said node with a Three-Button Dialog subVI, but it seems I haven't gotten it to work yet. I haven't really investigated that much, and I'm sure I can figure out what the issue is, but I thought I'd share my VI anyway. In addition to creating that VI, it also loads the NI.LV.All.OperatorInfo1 tag from the RealMatrix typedef as a working example.

It's worth pointing out, for anyone else who feels like experimenting, that there's a "Debug Operator Overloading" toggle in the Ned options, as well as an "Available Implementers" section in Heap Peek which seems to be related.

Operator Overloading Test.vi

Edited by flarn2006
Link to comment

So now i can just add my string instead of concatenating them! but joking aside, I feel like this should be an inherited property of LVobject.

19 hours ago, flarn2006 said:

I've attached a VI I was using to mess around with; it's supposed to create a string typedef which, when wired to a Multiply node, will replace said node with a Three-Button Dialog subVI

It's interesting if that is the way it works. usually for multiplies you would take the operation depending on the binary operator inputs types. e.g. if  you add u8 and a single float something would have to make a decision that upcasting to a single float is the right decision. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.