Article View: comp.std.c
Article #4323Re: Grammar for Switch Statement
From: Paul Long
Date: Thu, 02 Nov 1995 23:15
Date: Thu, 02 Nov 1995 23:15
37 lines
2575 bytes
2575 bytes
tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) wrote:
>In article <4797ni$avq@news0.rain.rg.net>, Paul Long <plong@perf.com> writes:
[snip]
>|> This is off-topic (not Standard-C related), but why do most
>|> programmers use parentheses around the value in a return
>|> statement? They are absolutely not needed, and I think it looks a
>|> lot cleaner without them. A colleague of mine said that she
>
>Wasn't it needed in some early versions of C? Maybe it is a frozen piece of
>history.
From "A brief(ish) description of BCPL" by Clive, it looks like a return value
is specified in BCPL with the RESULTIS command, which apparently doesn't
require parentheses (the RETURN command doesn't specify a return value). Alan
Watson posted an article in comp.lang.c that contains "very old C" that does
not have parentheses around the return-statement operand. Mark Brader posted an
article in comp.lang.c that contains this line in B:
return (f); /* at least, I think the () were required */
[His comment.]
(You guys have any further comment?)
It's interesting to note that in the code examples in K&R1, the return value is
always enclosed in parentheses, whereas in K&R2, the return value is _never_
enclosed in parentheses. The grammar in both versions show that parentheses are
not required.
This is what I bet happened: B may have required parentheses or at least this
was the convention. From the start, C did not require parentheses, but K&R1
showed the world code that had parentheses in return statements. K&R changed
their minds by K&R2, but the public hasn't picked up on the shift yet.
--
Paul Long 45:29:14N 122:48:09W
plong@perf.com http://www.teleport.com/~pciwww/
"Where time or intelligence are lacking, a goto may do the job."
- M.E. Hopkins, "A Case for the GOTO," 1972.
Technical Details
Message-ID:
<47bjej$ocf@news0.rain.rg.net>Path:
arc1-ca.pugleaf.net!newsfeed.internetmci.com!psgrain!rainrgnews0!usenetReferences:
<470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com> <4797ni$avq@news0.rain.rg.net> <47alln$ph1@newshost.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!psgrain!rainrgnews0!usenet From: Paul Long <plong@perf.com> Newsgroups: comp.std.c Subject: Re: Grammar for Switch Statement Date: 2 Nov 1995 23:15:31 GMT Organization: Performance Computing Incorporated Message-ID: <47bjej$ocf@news0.rain.rg.net> References: <470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com> <4797ni$avq@news0.rain.rg.net> <47alln$ph1@newshost.lanl.gov> NNTP-Posting-Host: yosemite.perf.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.1 sun4c) X-URL: news:47alln$ph1@newshost.lanl.gov