On Sat, 26 Aug 2006, Junio C Hamano wrote: > > > Now, admittedly it's wrong because another bad habit Junio picked up > > (doing comparisons with constants in the wrong order) > > I think you misunderstand the rationale used to encourage the > comparison used there. It does not have anything to do with > having comparison on the left. > > The comparison order is done in textual order. You list smaller > things on the left and then larger things on the right (iow, you > almost never use >= or >). Ahh. A number of people do the "0 == x" thing, because they want to be caught if they use "=" instead of "==" by mistake. I thought it was the same thing. > This does not come from any authoritative source, but I picked > it up because I felt it made a lot of sense. To anybody who has _ever_ done any math at all, it makes no sense at all. You _always_ put constants on the right-hand side (or, possibly last on the left-hand side, in order to make the right-hand side be "0"). Similarly, if you say it out loud, you'd always say "if 'x' is larger than or equal to zero", not "if zero is smaller or less than 'x'". That's because "zero" obviously never varies, so you'd never talk about "zero" being compared to anything else. The only exception would be the mathematical "0 < x < 10" kind of thing, which some languages (not C, of course) allows in that form. I can imagine that people would just do that as "0 < x && x < 10" just to keep the C form as close to the mathematical form, although I would at least personally do it as if (x > 0 && x < 10) especially if I ever needed to write it that way on multiple lines due to some of the expressions being more complicated. Linus - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html