Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is anybody using the named boolean operators?

Tags:

c++

boolean

Or are we all sticking to our taught "&&, ||, !" way?

Any thoughts in why we should use one or the other?

I'm just wondering because several answers state thate code should be as natural as possible, but I haven't seen a lot of code with "and, or, not" while this is more natural.

like image 679
stefaanv Avatar asked Jul 09 '09 11:07

stefaanv


2 Answers

I like the idea of the not operator because it is more visible than the ! operator. For example:

if (!foo.bar()) { ... }

if (not foo.bar()) { ... }

I suggest that the second one is more visible and readable. I don't think the same argument necessarily applies to the and and or forms, though.

like image 173
Greg Hewgill Avatar answered Oct 21 '22 14:10

Greg Hewgill


"What's in a name? That which we call &&, || or ! By any other name would smell as sweet."

In other words, natural depends on what you are used to.

like image 27
aherve Avatar answered Oct 21 '22 14:10

aherve