Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Unnecessary parentheses (Was: Help: VAX C problem) Message-ID: <1991Apr2.185204.20516@zoo.toronto.edu> Date: Tue, 2 Apr 1991 18:52:04 GMT References: <1991Mar30.161854.27378@cbnewsk.att.com> <4072.27f7215c@iccgcc.decnet.ab.com> <1991Apr1.203600.15721@zoo.toronto.edu> <1#.gqcm@rpi.edu> Organization: U of Toronto Zoology In article <1#.gqcm@rpi.edu> xor@aix01.aix.rpi.edu (Joseph Schwartz) writes: >>They used to be, actually, and many of the role models :-) for C programmers >>have habits dating back to the time when they were. > >Is this true? The grammar in K&R1 (pg 218) does not require parens in the >return statement. However, the example on page 68 (and indeed all of the >examples in the book) show the parentheses around the expression. It's true. A lot of us Real Old Timers remember when K&R1 came out. The parentheses stopped being mandatory somewhat before that. BWK and DMR picked up the habit when they were still required, as did others. >Another place I tend to see unnecessary parens is with the sizeof >operator. You can use "sizeof (typename)" or "sizeof expression"... >I often see "sizeof (expression)"... I think this is a combination of (a) paranoia about operator precedence, and (b) a general feeling that treating this funny operator as if it were a function gives a cleaner appearance. >Just curious...how often do you folks purposely insert unnecessary parens >into expressions? Sometimes I'll do it just to make the grouping clearer... Parentheses inserted to make grouping clearer are "unnecessary" only to the compiler; almost nobody really has the C precedence rules memorized. -- "The stories one hears about putting up | Henry Spencer @ U of Toronto Zoology SunOS 4.1.1 are all true." -D. Harrison| henry@zoo.toronto.edu utzoo!henry