On Saturday 16 October 2004 12:44 am, William Chops Westfield wrote: > On Oct 15, 2004, at 5:55 PM, steve@tla.co.nz wrote: > > The statement "if(3==foo)" is written in the opposite way to how you > > would describe what the statement is doing, so the statement isn't > > immediately and inherently self documenting. > > I dunno. It's just not ENGLISH. Mathematicians will consider > an equality statement fully reversable; "foo = 3" is precisely > identical to "3 = foo"; one of the foundations of algebra, sort of. To add to the arguement.... :-) If you look at the output of some compilers, you may find disagreement too. if (foo == 3) { would collect "foo" and subtract the #3 to test for zero if (3 == foo) { would collect 3, place it on the stack, then collect foo, then subtract foo from stack value "3" it doesn't seem to sound like much, but if you have seen a DWORD being done on a 16bit compiler, you do see a fair bit of juggling of values. To me, if (foo == 3) is just more "efficient" from a compiler point of view. likewise, I would also prefer to see complicated stuff on the left with simple stuff on the right... therefore, preference for: if (foo == 3) { if (function(foo) == 3) { if (function(foo1) == foo2) { if (function1(function2(foo1) == function3(foo2)) also in the name of efficiency, it makes sense to test for something more likely, then test for something less likely, so: (poor example, but hopefully conveys the idea) if ((c < 32) || (c == EOF)) { <- more likely to encounter c < 32 would be prefered versus: if ((c == EOF) || (c < 32)) { <- only going to encounter EOF only once _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist