Article View: comp.lang.c
Article #573Re: Taming The Switch-Statement
From: Keith Thompson
Date: Mon, 19 Oct 2026 22:48
Date: Mon, 19 Oct 2026 22:48
43 lines
3534 bytes
3534 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 2026-10-18 21:09, David Brown wrote:
>> On 18/10/2026 18:09, bart wrote:
>>> [...]
> [ declaration syntax ]
>
> (I just want to comment on a [not unimportant] detail...)
>
>> You need to give things in the right order, or use parentheses, to
>> get the right "type expression". It's just like any other kind of
>> expression.
>> The intention of the declaration syntax in C is that the declaration
>> order follows usage. [...]
>
> I think the first part is downplaying that languages typically indeed
> make a distinction between parenthesized expressions and declarations.
> Quite some other languages [not from the C-heritage] that I used all
> did not need to introduce "expression"-grouping for _declarations_ in
> the first place given their more consistent ways to declare entities.
Just one quibble. C's declaration syntax *is* consistent. Its
rules are rigorously specified by the standard, particularly by
the grammar.
Many of us (myself included) don't particularly like it, but that
doesn't mean it's inconsistent.
My own take on all this is that having declaration syntax follow usage
was a very clever idea, where "clever" is not necessarily a compliment.
It was IMHO unsuccessful in the sense that it can lead to confusing
and overly complicated declarations. (Other languages don't have tools
corresponding to cdecl for much the same reason that Spanish-speaking
countries don't have spelling bees.) But it was extraordinarily
successful in the sense that, even if you think it was a bad idea,
it wasn't bad enough to keep C from becoming one of the most popular
programming languages.
(I wonder if keeping the declaration-follows-use principle while
making "*" a postfix operator might have improved things.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11b66ng$2fcat$2@kst.eternal-september.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11arjmc$2qid7$1@dont-email.me> <11at5vi$5vu$1@reader2.panix.com> <11auad0$3no1k$1@dont-email.me> <11aupfl$3ul$1@reader2.panix.com> <11avmfb$55rt$1@dont-email.me> <11b2a6d$131h6$1@dont-email.me> <11b2hr6$15thq$1@dont-email.me> <11b2l06$16mof$1@dont-email.me> <11b2qv0$19h68$1@dont-email.me> <11b35gt$1cn63$2@dont-email.me> <11b557o$1kr9u$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Mon, 19 Oct 2026 15:48:16 -0700 Organization: None to speak of Lines: 43 Message-ID: <11b66ng$2fcat$2@kst.eternal-september.org> References: <119qf6l$2rmg3$1@dont-email.me> <11arjmc$2qid7$1@dont-email.me> <11at5vi$5vu$1@reader2.panix.com> <11auad0$3no1k$1@dont-email.me> <11aupfl$3ul$1@reader2.panix.com> <11avmfb$55rt$1@dont-email.me> <11b2a6d$131h6$1@dont-email.me> <11b2hr6$15thq$1@dont-email.me> <11b2l06$16mof$1@dont-email.me> <11b2qv0$19h68$1@dont-email.me> <11b35gt$1cn63$2@dont-email.me> <11b557o$1kr9u$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 19 Oct 2026 22:48:17 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="2601309"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L18jw6RWuTQ0IL26xyaq0"; posting-host="9660475a9289184964a5dc25cbc4aed9" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:FaYOuq+Uh2j40NYvypN30M58EkU= sha256:cI0V6XG+SvtCwq5PCOy1NqTlCenyb1kPjUSmTkaDYyM= sha1:y5e6zYT66lNgMw5e2kWkrMxVWTw= sha256:LyXSVUnrixAs7S8iaUxb7k7oz6l55hCiYrwruwM6z7A=