LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Darin.K

Numeric conversions should accept boolean inputs

Status: New

My LV intellisense prototype has been telling me something very interesting recently.  When I use it on a Boolean to 0,1 node, it really, really thinks I want to put in an I32 numeric conversion.  Looking deeper, almost everytime I forgo the I32 conversion I am utilizing an implicit coercion.  What I have not wanted, probably since the LV4 days is an I16. 

 

The following suggestion is a marginal improvement:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Change-Output-Representation-on-quot-Boolean-to-0-1-qu...

 

I like output configuration myself, but it can be easily hidden from beginners, and not-quite-beginners alike:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-Output-Configuration-for-the-Compound-Arithmetic...

 

And teaching people about it is not enough sometimes: Smiley Surprised

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Output-Configuration-for-Add-Multiply-Array-Elements/i...

 

So I suggest skipping the middle man and allowing the numeric conversion functions to accept booleans directly.  So simple even a text programmer can do it.

 

BooleanConversion.png

 

14 Comments
tomlawton
Member

Nice idea... Apart from the use of "Show terminals as icons".. 😉

 

Jim_Kring
Trusted Enthusiast

true convert to one?

coerced by Darin's logic,

this gets a kudo.

altenbach
Knight of NI

We could take it even a small step further and allow simple arithmetic operations between numerics and booleans, e.g. "N + boolean" would be either N or N+1. "N * boolean" would be either zero or N, etc. (probably should show a coercion dot, but still....)

kegghead
Member

I'd argue it's not the job of the explicit numeric conversions to do this. Who's to say what a True value is (other than nonzero in LabVIEW's case)? I'd rather see the behavior of the Boolean To 0,1 primitive changed based on my comment I just posted on Jack's idea-- where the output just automatically adapts to the downstream node.

altenbach
Knight of NI

> Who's to say what a True value is ...

 

Well, in this case the behavior can be fully documented in a small sentence. No need to get philosophical. 😉

 

(Other languages are similar here, look e.g. at the bottom of this python documentation)

 

Implementing this idea would make the "boolean to 0,1" primitive completely obsolete, simplifying the palettes. I am all for it.

 

X.
Trusted Enthusiast
Trusted Enthusiast

Heck, I'd say connect the boolean to the numeric DIRECTLY and throw a coercion dot! Your suggestion is so 2013...

After all, you can connect an error cluster to a boolean primitive:

 

ScreenHunter_001.jpg

 

But an LV Intellisense prototype? That sounds fun.

Darin.K
Trusted Enthusiast

> But an LV Intellisense prototype? That sounds fun.

 

Do not want to derail the discussion, but it is very interesting.  I construct an edge weighted directed graph containing the primitives I have used in my VIs.  The edge weighting is probability that I have connected the two together.  I was looking at some stats and noticed a heavy edge weighting between the Boolean to 0,1 and the To I32 node.

 

By far the coolest effect is that I can actually think two moves ahead, not only can I sometimes predict what I want to place next, but even the node after that.  As I have described elsewhere, I have replaced QD with a graphical version which I call SpeedDrop (how original).  When I put it in hopscotch mode and select a node it autopopulates the results window with the nodes most likely to be connected to it.  I need a few tweaks to get the realtime performance up to my liking and it would need training VIs from a variety of users to make it generally useful.

 

It also tells me that Obtain Queue is often followed directly by Enqueue Element. 

altenbach
Knight of NI

> We could take it even a small step further and allow simple arithmetic operations between numerics and booleans, e.g. "N + boolean" would be either N or N+1. "N * boolean" would be either zero or N, etc. (probably should show a coercion dot, but still....)

 

I made a seperate idea for this to keep things organized.

ouadji
Trusted Enthusiast

You often have very good ideas Darin, but I don't like this one.


how to say ... with my poor english ... hummm ...

 

i will try to do my best,
This idea is certainly convenient in terms of programming
but this idea removes the "primary/original" meaning of the boolean.
I think this idea will make the BD least understandable at first glance,
and could bring confusion.
In my case, I prefer to keep a conversion function between Boolean and munéric.

Darin.K
Trusted Enthusiast

We shall have to agree to disagree.  I find it readable and it gives me code that runs twice as fast in half of the time.