Re: 3.0.3
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> May 12, 2007
- 717 views
Derek Parnell wrote: > > Jeremy Peterson wrote: > > > > Juergen Luethje wrote: > > > > > > Helo Rob, > > > > > > maybe you can add something like the following to 'misc.e': > > > }}} <eucode> > > > global constant > > > FALSE = 0, > > > TRUE = not FALSE > > > > > > global type boolean (object x) > > > if integer(x) then > > > return x = FALSE or x = TRUE > > > else > > > return FALSE > > > end if > > > end type > > > </eucode> {{{ > > > > > > I think it would be pretty useful. > > > > > > Regards, > > > Juergen > > > > Why not just > > > > TRUE = 1 > > Because it removes implementation dependancies. > > It is generally accepted that when the concept 'FALSE' is implemented as an > integer, the value zero is used. However, there are quite a few different > implementations > of 'TRUE', some use 1, some -1, and some use every non-zero value. By defining > 'TRUE' as 'not FALSE' it will work with any implementation. > > > Alsoh due to a quirk in the way that short-circuit IF evaluations work, it can > be made to execute faster when the conditions are separated out ... > > }}} <eucode> > global constant > FALSE = 0, > TRUE = not FALSE > > global type boolean (object x) > if not integer(x) then return FALSE end if > if x = FALSE return TRUE end if > if x = TRUE return TRUE end if > return FALSE > end type > </eucode> {{{ > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Isn't
global constant FALSE = 0, TRUE = not FALSE global type boolean(integer x) return x = x = TRUE end type
even faster? CChris