Re: ESL Master Include File
- Posted by "Juergen Luethje" <j.lue at gmx.de> Jul 26, 2005
- 561 views
Derek Parnell wrote: > Pete Lomax wrote: > > [snip] >> Despite the highly unlikely chance >> of such things, some libraries actually do define TRUE=(1=1) and >> FALSE=(1=0). > > That would be me > >> There is nothing wrong with using tri-logic with say isTLtrue=1, >> isTLunknown=0, and isTLfalse=-1, (though isTLfalse=0, and >> isTLunknown=-1 would probably be just as effective) but >> defining FALSE as -1 is just brain-dead stupidity. > > Why? The only requirement is that TRUE and FALSE have different values > from each other. One could have ... > > constant TRUE = 't', > FALSE = 'f' > > And all code that relied on using TRUE and FALSE would still work. > One's code should never be doing arithetic on boolean values and never > doing relative comparisions either (less than, greater than). Instead > one's code should only be doing assignments and equality tests. What about boolean operations such as 'not'?
constant FALSE = 0, TRUE = 1 ? TRUE = not FALSE -- prints 1 (which equals TRUE here) -> correct
constant FALSE = -1, TRUE = 1 ? TRUE = not FALSE -- prints 0 (which is not a boolean value here!)
constant FALSE = 'f', TRUE = 't' ? TRUE = not FALSE -- prints 0 (which is not a boolean value here!)
> BTW, and I'm sure you already know this, but there are plenty of > languages that implement TRUE as -1 instead of 1. Then hopefully the boolean operators in these languages work consistently, so that always not FALSE = TRUE not TRUE = FALSE FALSE xor TRUE = TRUE etc. Regards, Juergen