🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #568

Re: Taming The Switch-Statement

#568
From: bart
Date: Mon, 19 Oct 2026 21:28
83 lines
5515 bytes
On 19/10/2026 14:46, David Brown wrote:
> On 19/10/2026 15:16, Janis Papanagnou wrote:
>> 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.
>>
>> The second part is, as I had understood C's history, the idea behind
>> how it got defined; needless to say that I think that was a bad idea.
>> But that's what we've got! If they had dropped that requirement/idea
>> the declaration syntax could have become "better" (more consistent,
>> less cryptic, less convoluted, clearer). Now, after half a century,
>> we just have to live with that, and folks who have "problems" with it
>> should better not touch this language (or maybe not doing programming
>> at all). The somewhat tragic aspect is that the "declaration follows
>> use" idea was (IIRC) intended to _simplify_ the understanding of its
>> concepts and use of the language; the consequences were seemingly not
>> valued correctly.
>>
> There are a number of things that I don't particularly like about C's 
> declaration syntax, or where I think it would have been better if it 
> were different.  But the "inside-to-outside" ordering is not one of 
> them.  That is not because I think it is better or clearer than left-to- 
> right ordering, but because when I compare to, say, Pascal, it's not a 
> big issue for me.  Far bigger are :
> 
> 1. People put too much into a single type declaration, rather than 
> building types out of logical parts with a purpose and a name.  They 
> don't do it as much as Bart likes to pretend, but some people do it too 
> much for my liking.  The language doesn't force you to do that - it's 
> programmer style.  IMHO there is never a reason for a "pointer to an 
> array of function pointers taking int and returning void" - no matter 
> what syntax is used.

Then you have a peculiar and restricted coding style.

(Funny that when I suggest that nested loop breaks are uncommon, 
everyone says I'm wrong! Some even write 200-line made-up examples to 
prove their point.)

These are two actual function pointer arrays from my projects (not C):

     []ref proc hosthandlers = ...

     [pclnames.len]ref proc(pcl) px_handlertable

There is no reason to abstract away that function pointer type.

You probably do so in C /because/ the type involves * () and [] but have 
somehow persuaded yourself that it just better that way.

Note that 'pcl' in my example /is/ a typedef; here it makes sense as it 
is used in 100s of places. This function pointer occurs in only one place.

(The C version looks like: 'void (*name[N]))T)'. I used a tool and 
transcribed it, then I double-checked and found I'd written '(*name)[N]' 
not '(*name[N])'; I wouldn't have noticed.)

BTW what name would be given to such a function pointer type? There is 
nothing obvious other than 'funcptr', but suppose there is more than one 
in scope?

Something else strikes me about breaking up a complex type-decl sequence 
into a chain of typedefs: if you take that list of typedefs, and rotate 
it 90 degrees c/w, you have something that resembles the LTR representation!

Technical Details
Message-ID: <11b6224$2ejik$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> <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> <11b56uo$1q18k$5@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!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Mon, 19 Oct 2026 22:28:34 +0100
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <11b6224$2ejik$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> <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>
 <11b56uo$1q18k$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Oct 2026 21:28:37 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2575956"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19+1QhzStWu+1pEN9tFdCl+"; posting-host="490a98fc4950ca5dcdd86ea57e554712"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:u/HUlzK7c2jIFN++IjXGNyTSImw= sha256:73XT2wlOc/Z89yRLJu1oOwVb/P4IytATOHjqPT+1vdQ=
	sha1:7f6Vlf9L8gXXSRAd9+YCLfBejHc= sha256:O73ZvbCpL6gjN17A30OHNO+L1gg98BqxiQ2+NvoB0LY=
Content-Language: en-GB
In-Reply-To: <11b56uo$1q18k$5@dont-email.me>