Re: [AD] TRUE and FALSE

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tuesday 22 April 2003 2:38 pm, Hein Zelle wrote:
> Ben Davis wrote:
> > This has bugged me for ages. Why is TRUE defined as -1?
>
> Because the author used too much (visual) basic? :-) We had lots of
> beautiful bugs in a C++/VB combination where both sides of the program
> would write different values of "True" in the database. Yummie. I'm
> not sure if it's just VB, but -1 for true is definitely not uncommon.

Yep. BBC BASIC and QB both use -1 for true. I should imagine it's common to 
all BASICs.

> > The canonical truth value in C is 1. Would it break too many
> > programs to change it? Or could it be deprecated in favour of
> > AL_TRUE (and AL_FALSE) perhaps?
>
> If you program "right" it shouldn't bother you in the first place. You
> should always use x = TRUE, if (x == TRUE) or if (x), and either will
> work as long as you are consistent. Using things like "x = 1; if (x ==
> TRUE)" is asking for trouble, in any program.

x = FALSE;
x = !x;
if (x == TRUE) ...

Ben




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/