Re: [AD] TRUE and FALSE

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


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. 

> 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. 

That also illustrates that it probably cannot be changed safely: if
you need it changed that means your program is not written "properly",
and since others probably did the same with the "allegro" value of
TRUE, so changing it would break their programs. Hmmmz. You could
argue that everybody should program the "right" way, but if they did
the change wouldn't be necessary ...

	 Hein Zelle

>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-< 
 Unix is user friendly. It's just very particular about who 
 it's friends are.

 Hein Zelle                     hein@xxxxxxxxxx
	                        http://www.icce.rug.nl/~hein
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<




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