Precedent for use of =
Charley Wingate
mangoe at umcp-cs.UUCP
Thu Jul 10 15:20:21 AEST 1986
Dave Haynie writes:
>> Personally, I still prefer := for assignment and = for equality over =
>> and ==. I also think that the keystroke argument is ridiculous. The
>> problem with = and == is further aggravated by the fact that in C an
>> assignment is an expression and not a statement, so that code like
>> if (i = 0) {
>> /* do something */
>> }
>> else {
>> /* do something else */
>> }
>> is legal C and usually /* does something else */ than you expected :-)
>As long as you're writing in C, and you REALLY know the language, the above
>construct would be ridiculous. I think that most of the folks that are
>unhappy with the way that C handles = and == are frustrated Pascal hackers
>who can't quite adjust to the power and terseness of C. Maybe if they'd
>spend a few extra hours LEARNING C instead of trying to write Pascal in C,
>they'd be much better off.[...] My point is instead of
>tripping over the language syntax and screaming how it should be changed,
>one can learn the language and then not have to worry about tripping over
>it. And then you might even start to realize why a particular method has
>its advantages.
Unfortunately, it's that kind of attitude that leads to the perpetuation of
bad language constructs.
C's handling of assignment and equality is a problem: it is error-prone.
What's worse is that one often sees code like "if (a=b)" done on purpose--
yet another example on how the "power and terseness" of C leads to
obfuscation.
C. Wingate
More information about the Comp.lang.c
mailing list