What should be added to C : if (a=b)
David Keppel
keppel at pavepaws.berkeley.edu
Thu May 29 02:19:03 AEST 1986
< munchies! >
[ discription of problem "'if (a=b)' when I wanted 'if (a==b)'" ]
How about an option to lint(1) (this doesn't help the people who
don't have lint) that looks for conditional clauses with assignment
but no test. Thus
if ( (a = expr) == value ) { ...
would pass cleanly thru lint, while
if ( a = expr ) { ...
would generate a message indicating a potential problem. There
could be a "lint comment" /* BOOLTESTED */ or some such:
if ( a = expr ) { /* BOOLTESTED */
that would also serve as documentation to say to another reader of
the code "Yes, I really meant '=' and not '=='".
----
David Keppel ..!ucbvax!pavepaws!keppel
"Gospel in, Gospel out: Learning by Osmosis"
More information about the Comp.lang.c
mailing list