NOT operator like AndAlso/OrElse?

For other topics related to the FreeBASIC project or its community.
Imortis
Posts: 1548
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

NOT operator like AndAlso/OrElse?

Postby Imortis » Nov 08, 2017 19:52

AndAlso and OrElse are not bitwise like AND and OR. They function like boolean operators, and even return Booleans when used with Boolean values.

Should we have something similar for NOT?

Not is currently a bitwise compliment. Should we have a not operator that always returns a -1 or 0 (TRUE or FALSE)? If so, what do we call it? ButNot?
dkl
Site Admin
Posts: 3191
Joined: Jul 28, 2005 14:45
Location: Germany

Re: NOT operator like AndAlso/OrElse?

Postby dkl » Nov 08, 2017 19:59

You could say that "= 0" or "= false" is that operator. That's what I ended up doing anyways.
Imortis
Posts: 1548
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: NOT operator like AndAlso/OrElse?

Postby Imortis » Nov 08, 2017 20:03

dkl wrote:You could say that "= 0" or "= false" is that operator. That's what I ended up doing anyways.

Sure, that is an easy work around. I was just curious if it would be a good idea to have something similar to the short-circuit ops to be consistent.
MrSwiss
Posts: 2468
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: NOT operator like AndAlso/OrElse?

Postby MrSwiss » Nov 08, 2017 20:13

How about (single line) macros:

Code: Select all

#Define IsFalse(e)  ( Not CBool(e) )
#Define IsTrue(e)   ( CBool(e) )
They check whether 'expression' is: True/False ... ( IsFalse() is IMHO, more 'telling', than IsNot() )

Return to “Community Discussion”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests