🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #536

Re: Taming The Switch-Statement

#536
From: Keith Thompson
Date: Mon, 19 Oct 2026 02:37
35 lines
2715 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Sun, 18 Oct 2026 23:51:25 -0000 (UTC), Waldek Hebisch wrote:
>> Writing statement with parentheses may look silly, but such code may
>> be easily produced due to use of macros.
>
> Why do you need to distinguish between “statements” and “expressions”,
> anyway?

Because C strongly distinguishes between statements and expressions.

If you don't want to make that distinction, you'll need to use a
different language.

(The context was that a suggested change to C would be syntactically
ambiguous.)

> By the way, the precursor of C, BCPL, allowed statement sequences
> inside expressions. For some reason this got dropped from C.

Yes.

There is a proposal to add statement expressions to C, based on
the existing gcc extension.  This is not reflected in the latest
C2y draft.

Note that statements and expressions are still distinct.  An
expression statement can be formed from an expression by adding
a semicolon.  A statement expression (given the extension) can be
formed from a compound statement by adding parentheses.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3643.htm

-- 
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: <11b3vpg$1md9i$1@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-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11b2eck$3pvd9$1@dont-email.me> <20261018171339.00005308@yahoo.com> <11b2pq5$3pvda$7@dont-email.me> <11b3gkj$mt2$1@reader2.panix.com> <11b3m1r$3tp6p$1@paganini.bofh.team> <11b3tc5$1lgro$3@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: Sun, 18 Oct 2026 19:37:36 -0700
Organization: None to speak of
Lines: 35
Message-ID: <11b3vpg$1md9i$1@kst.eternal-september.org>
References: <119qf6l$2rmg3$1@dont-email.me> <11b2eck$3pvd9$1@dont-email.me>
	<20261018171339.00005308@yahoo.com> <11b2pq5$3pvda$7@dont-email.me>
	<11b3gkj$mt2$1@reader2.panix.com> <11b3m1r$3tp6p$1@paganini.bofh.team>
	<11b3tc5$1lgro$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Oct 2026 02:37:37 +0000 (UTC)
Injection-Info: kst.eternal-september.org;
	logging-data="1783090"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1892F/wBHWg52hn/EOFCGg+"; posting-host="9660475a9289184964a5dc25cbc4aed9"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:aIAmiXWRmPf7Gne0ZH57FsyhXNk= sha256:OqUSleBprTgdS9Vib6ZX2dQMBkYNcRXAnKUeMIgZLUw=
	sha1:Wg+2rh9MIaLcgSyWAWQpSX6tsYQ= sha256:O6lFuCsqB8bCgLklvvFKrTqcc80uJXAbcqTWCPZVrXw=