return <expression> -vs- return(<expression>)

bet at ecsvax.UUCP bet at ecsvax.UUCP
Sat May 19 02:08:25 AEST 1984


So much complaining about return(<expression>)!
I have always coded it that way, and intend to continue. In fact, I didn't
realize that "return <expression>" was legal until this discussion -- I learned
C by reading K&R, and didn't dwell much on the C reference in the back. If you
look through the book you see that most (all that I could find) instances of
and references to the return statement *except* the entry in the "C reference
manual" use parentheses. Someone somewhere, whose opinion is held in some
esteem (judged by the reverence in which this book is held in discussion in
this group) seems to consider return(<expression>) *good* style. People
are complaining that it looks like a function call; so does the while
statement when followed by a null statement, which doesn't bother me at all.
The C language uses a concept called *reserved words*. For those of you in the
know, this can make the job of the compiler easier -- the lexical analyzer
can catch these suckers with very little work, simplifying the parse. Well,
*I* also understand reserved words, and recognize them in reading code.
return(<expression>) doesn't look like a function call, because "return"
is a reserved keyword. The syntax of the while statement looks like

	while(<expression>) statement

If we eliminated the parentheses we would probably need to make a new reserved
word part of the while statement. And the for statement probably wouldn't
survive in its current generality. The simplification that comes from using
parentheses (overloading them) to delimit parts of statements I like.
Recognizing these things in code causes me no trouble. The compiler uses
reserved words, and so do I. Out of curiosity, where did this vociferous
body of users learn C? Surely not from K&R!
					Bennett Todd
					...{decvax,ihnp4,akgua}!mcnc!ecsvax!bet



More information about the Comp.lang.c mailing list