(Un)necessary parenthesis

Ray Dunn ray at micomvax.UUCP
Fri Jul 8 00:45:24 AEST 1988


In article <570 at splut.UUCP> jay at splut.UUCP (Jay "you ignorant splut!" Maynard) writes:
 >In article <8209 at brl-smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
 >>	return 0;		/* intuitive */
 >
 >To a FORTRAN programmer.
 >
 >>	return(0);	/* one wonders why the () are there */
 >
 >1) Because it looks consistent.
 >2) It's intuitive to a converted Pascal or PL/I programmer.
 >3) The programmer has gotten used to putting parentheses around just about
 >   everything.   

4) Because, in fact, the *parenthesised* version is intuitive to some people.

5) Because people think of return(x) as a *call*, or at least syntactically
   similar to a call.  Otherwise what is it, a unary pre-fix operator?  There
   is little precedent for that form using an identifier other than + and -. 

6) Because K&R 1 page 68 says:

   "The return statement is the mechanism for returning a value from the
    called function to its caller.  Any expression can follow the return:
          return(expression)"

   This form is used throughout the book, other than in the definition in
   the Appendix A reference manual (!).

7) Because the MS C 5.1 Users Guide Language Reference Section 6.11 says:
   (OK - I know this is in no way a definitive document!!)

   "By *convention* [my emphasis], parenthesis enclose the expression
    argument of the return statement.  However, C does not require the
    parenthesis."

8) Because other keywords in 'C' use parenthesis when other syntax would
   be just as "natural" - for (...), while (....), do..while (...),
   switch (...), etc. This is probably the same reason as 1) above.

   Many people even do not put a space before the opening "(" in these cases,
   which in my opinion is even "worse" (whatever that means) than parenthesis
   after return.
.
.
.
1001) Because they *want* to do it that way!

-- 
Ray Dunn.                      |   UUCP: ..!{philabs, mnetor}!micomvax!ray
Philips Electronics Ltd.       |   TEL : (514) 744-8200   Ext: 2347
600 Dr Frederik Philips Blvd   |   FAX : (514) 744-6455
St Laurent. Quebec.  H4M 2S9   |   TLX : 05-824090



More information about the Comp.lang.c mailing list