C style peeve

Andrew Koenig ark at alice.UUCP
Mon Mar 19 00:10:32 AEST 1990


In article <2205 at osc.COM>, jgk at osc.COM (Joe Keane) writes:

> It's a shame the compiler lets them get away with it, and i think the extra
> parentheses should be strictly illegal.  Unfortunately, for some reason the
> ANSI committee didn't like this suggestion.

For one thing, it would be the only place in the entire language
where it would not be legal to wrap a pair of parentheses around
an expression without changing its meaning.

That is,  (x)  is a perfectly good expression, so why shouldn't I
be able to use it in a return statement, as

	return  (x)  ;

??

A historical note: parentheses are required in return statements in
PL/I.  This is because PL/I keywords are not reserved words, so the
parentheses are necessary to resolve the following ambiguity:

	return (x) = (y);

Does this return the Boolean value of the comparison between x and y,
or does it set element number x of an array named `return' to y?
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list