condition convention 'if (10 == j)...'
Michael Mc Namara
mac at tesla.UUCP
Wed May 1 18:00:04 AEST 1985
In article <2140 at sun.uucp> shannon at sun.uucp (Bill Shannon) writes:
>> > 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
While we're setting nets for ourselves, why not
# define .EQ. ==
Then we can say if ( j .EQ. 10 ) fortran--;
I believe all this belongs in the crutch box of (weak *) programmers;
Sure, you CAN do it if you WANT to, but I'll just
%s/.EQ./==/g^M/# define == ==^Mdd^M all your files ;-))))))))
^
|
necessary due to first command (-:
^
|
so whats the matter with lefties?
----------------------------------------------------------------------------
I want to go where the climate suits my clothes | mac at tesla | What article?
----------------------------------------------------------------------------
More information about the Comp.lang.c
mailing list