condition convention 'if (10 == j)...'

Bill Shannon shannon at sun.uucp
Sat Apr 27 15:58:39 AEST 1985

> > To prevent silly mistakes like 
> > 	if (j = 10)
> > I usually write
> > 	if (10 == j)
> > By putting the constant first, I ensure that the compiler will catch the 
> > typo.
> I think this is a good idea.  Any criticisms?  The only problem
> I have with it is that I am not accustomed to reading code written
> this way.
> -- 
> Gordon A. Moffett               ...!{ihnp4,cbosgd,sun}!amdahl!gam

What do you mean, any criticisms?  This is one of the most ugly
perversions of C I've ever seen!  I tend to read this in terms of
"if variable equals constant" and try to figure out how the value
"10" is ever going to change!  YUCK YUCK YUCK!!!!

People that write "if (10 == j)" probably also write "while (1)".
What do you mean, "while 1"???  Are you expecting "1" to change???
Everyone knows this should be written "for (;;)", read "forever".

					Bill Shannon

More information about the Comp.lang.c mailing list