🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4320

Re: Grammar for Switch Statement

#4320
From: Tanmoy Bhattacharya
Date: Thu, 02 Nov 1995 14:47
34 lines
2074 bytes
In article <4797ni$avq@news0.rain.rg.net>, Paul Long <plong@perf.com> writes: 
<snip>
|> >Next question is why they require parentheses...
|> 
|> I see what you mean--switch doesn't really need parentheses.
|> (That is, if we keep the case keyword. For example,
|> "switch 5+2 case -3:..." is okay, whereas "switch 5+2 -3:..."
|> is ambiguous.) Maybe it was done to make it look like the
|> other control statements, which need parentheses (for example,
|> "if a + 3;" would be ambiguous). I'll bet that's it.

Isn't `switch (5) - 3;' perfectly valid though useless (i.e. has
the same effect as the null statement) statement? I think the
grammar becomes ambiguous the moment `statement' is allowed to follow
`expression' without any delimiter.

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

Cheers
Tanmoy
-- 
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID: <47alln$ph1@newshost.lanl.gov>
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
References: <470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com> <4797ni$avq@news0.rain.rg.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
Newsgroups: comp.std.c
Subject: Re: Grammar for Switch Statement
Date: 2 Nov 1995 14:47:19 GMT
Organization: Los Alamos National Laboratory
Distribution: world
Message-ID: <47alln$ph1@newshost.lanl.gov>
References: <470ih7$mvh@gaia.ns.utk.edu> <4713rc$3d9@solutions.solon.com> <476n45$8g0@jrdgwm.jrd.dec.com> <4797ni$avq@news0.rain.rg.net>
NNTP-Posting-Host: qcd.lanl.gov