🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4332

Re: Grammar for Switch Statement

#4332
From: Zefram
Date: Sun, 05 Nov 1995 00:10
26 lines
1350 bytes
Norman Diamond <diamond@jrd.dec.com> wrote:
>Next question is why they require parentheses when return and sizeof don't
>require parentheses around the expression.  Next, why did they spell out
>the word in full, and why did they waste two keywords (swit and case) when
>they could have done it in one.

return doesn't require parentheses because it's unambiguous without.
sizeof is unambiguous (by definition, because of its defined precedence
as an operator), but arguably should require parentheses.  switch would
be ambiguous: is

switch a * b ;

equivalent to

switch ( a ) * b ;

or

switch ( a * b ) ;

?  switch and case can be combined unambiguously, but only because of
the colon required at the end of the case.  Making them separate
keywords makes parsing simpler, and makes code easier to understand.

-zefram
Technical Details
Message-ID: <1995Nov5.001024.18958@dcs.warwick.ac.uk>
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
References: <470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
From: A.Main@dcs.warwick.ac.uk (Zefram)
Subject: Re: Grammar for Switch Statement
X-Nntp-Posting-Host: stone
Message-ID: <1995Nov5.001024.18958@dcs.warwick.ac.uk>
Sender: news@dcs.warwick.ac.uk (Network News)
Organization: Department of Computer Science, Warwick University, England
References: <470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com>
Date: Sun, 5 Nov 1995 00:10:24 GMT