🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4326

Re: Grammar for Switch Statement

#4326
From: Lawrence Kirby
Date: Fri, 03 Nov 1995 01:23
28 lines
2086 bytes
In article <47bjej$ocf@news0.rain.rg.net> plong@perf.com "Paul Long" writes:

>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.

I don't have K&R in front of me but I did check up on this not so long ago.
If you look up return in the index there are something like 4 references to
it, 3 in the tutorial, one in the language reference section. From the way
return is described in the tutoral gives every indication that the
parentheses are mandatory. Only the syntax in the reference section indicates
that they are not.

But consider somebody learning the language. What is the chance of them
checking up on the precise syntactic details of return in the reference
section (the tutorial seems pretty clear and there isn't much to query).
Even if you read all through the reference section it is easy to miss.
So I reckon K&R created the false notion that parentheses are required. I
learnt C from K&R and I spend years believing that parentheses were
required. I thought the dropping of parentheses was a new-fangled ANSI
thing! :-)

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <815361792snz@genesis.demon.co.uk>
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
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> <47bjej$ocf@news0.rain.rg.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
From: Lawrence Kirby <fred@genesis.demon.co.uk>
Newsgroups: comp.std.c
Subject: Re: Grammar for Switch Statement
Date: Fri, 03 Nov 95 01:23:12 GMT
Organization: none
Message-ID: <815361792snz@genesis.demon.co.uk>
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> <47bjej$ocf@news0.rain.rg.net>
Reply-To: fred@genesis.demon.co.uk
X-NNTP-Posting-Host: genesis.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27