🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #517

Re: Taming The Switch-Statement

#517
From: bart
Date: Sun, 18 Oct 2026 17:34
56 lines
3755 bytes
On 18/10/2026 15:24, Michael S wrote:
> On Sun, 18 Oct 2026 13:22:52 +0200
> David Brown <david.brown@hesbynett.no> wrote:
> 
>>
>> To me, that is just as much gibberish as the original C.  No syntax
>> is going to make sense of it - no amount of "ref" or "func" or
>> pre-fix array notation will help.
>>
> 
> [O.T.]
> Prefix array notation would not. But postfix * notation would, somewhat.
> 
> It would be interesting to find out why designers of C, or of one of its
> ancestors decided that * as prefix is preferable to * as postfix.
> Were they afraid of confusion with usage of * as multiplication?
> Probably not, because confusion can arise about equally both for prefix
> and for postfix.
With all the other questionable choices, there probably wasn't much 
rationale involved. And there seemed to be little oversight too: other 
people weighing in with their opinions.

That particular choice had several consequences:

* If P is a pointer to a struct, then you have to write (*P).m instead 
of P*.m.

* That led to people using "->" instead (I don't know if that was 
introduced for this reason). But that only works for one level: (**Q).m 
still needs (*Q)->m. With postfix it's tidier and consistent: Q**.m

* The same when P is a pointer to an array. Pointers to arrays (real 
ones of type (T(*)[] not the T* idiom), are rarely used in C, possibly 
for the reason that indexing would look like (*P)[i], instead of P[i].

With postfix, it would be the marginally tidier P*[i]. Although here, 
even if unambiguous, the use of "*" looks odd.

In the event, everybody uses T* for 'array pointers' instead, which is 
less type-safe.

With function pointer derefs, it would be P*(x) which /is/ ambiguous, 
although for some obscure reason, function pointers don't need to be 
dereferenced: P(x) would still work.

* Then we get to type syntax. I think this simplifies a little: * and [] 
modifiers will always be to the right of a variable. Parentheses for 
precedence might disappear too. Types will be a little easier to get 
right and to grok.


When C was created, Pascal with its '^' postfix deref op already 
existed. Although C claims to have some Algol 68 influence (I can't see 
it!) it seems to have ignored Pascal completely.

Technical Details
Message-ID: <11b2vvq$1bilt$1@dont-email.me>
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!.POSTED!not-for-mail
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> <20261018172446.00002d43@yahoo.com>

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!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Sun, 18 Oct 2026 18:34:49 +0100
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <11b2vvq$1bilt$1@dont-email.me>
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> <20261018172446.00002d43@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Oct 2026 17:34:51 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1428157"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/DdJJ01XpNwP/KAOV94/Le"; posting-host="c99c9a957370eff0b06f081ccfe4e16c"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HpewGGFOKHl9eo00Q2eakWPJOTE= sha256:bW7UgIhUpe1Nix0vhtTdPkKhTsVPC4+uYG3S9Ro5Fq0=
	sha1:0weoNWhtpE3hIR0TjB/vYKhmfO4= sha256:pdBJIXDdWBuuQiUc3ryKqkvfei4SoNueVXTbc0mmfks=
Content-Language: en-GB
In-Reply-To: <20261018172446.00002d43@yahoo.com>