NOT operator like AndAlso/OrElse?

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
Imortis
Moderator
Posts: 1926
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

NOT operator like AndAlso/OrElse?

Post by Imortis »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: NOT operator like AndAlso/OrElse?

Post by dkl »

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

Re: NOT operator like AndAlso/OrElse?

Post by Imortis »

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: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: NOT operator like AndAlso/OrElse?

Post by MrSwiss »

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() )
Post Reply