Re: 3.0.3
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> May 13, 2007
- 733 views
Derek Parnell wrote: > > CChris wrote: > > > Isn't > }}} <eucode> > global constant > FALSE = 0, > TRUE = not FALSE > > global type boolean(integer x) > return x = x = TRUE > end type > </eucode> {{{ > > even faster? > > > > Probably, but is not exactly clear at first reading. You have to think it > through > to see that it works. The primary purpose of any programming language ought > to be to help communicate your intentions to humans who read the code, so I > recommend that coders, as a first priority, try to make code clear before > trying > to make it as fast as possible. > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell I agree with this statement in 90% of cases. The main exception, which covers the case at hand, is for low level stuff which is executed implicitly tens or hundreds of times in about any reasonably complex programs - put "Hello, world!" aside. Why? Because these things are usually invisible, and hardly anyone bothers to read them. Hence the readibility issue, for this class of utility code, is probably less important han reliability and speed. Nothing prevents anyone to code the human friendly way in a block comment, and then put in actual code which works, but is a little less clear. CChris PS for Pete: anyway, I'd expect boolean() to crash if fed a sequence, so my routine can indeed be used as a function. If you want a return of 0 for sequences, then indeed it is not suitable.