Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!pyramid!prls!philabs!micomvax!ray From: ray@micomvax.UUCP (Ray Dunn) Newsgroups: comp.lang.c Subject: Re: (Un)necessary parenthesis Message-ID: <1173@micomvax.UUCP> Date: 7 Jul 88 14:45:24 GMT References: <326@marob.MASA.COM> <8209@brl-smoke.ARPA> <570@splut.UUCP> Reply-To: ray@micomvax.UUCP (Ray Dunn) Organization: Philips Electronics Ltd. (TDS - Montreal) St. Laurent QC, Canada Lines: 52 In article <570@splut.UUCP> jay@splut.UUCP (Jay "you ignorant splut!" Maynard) writes: >In article <8209@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) 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