🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #496

Re: Taming The Switch-Statement

#496
From: Janis Papanagnou
Date: Sun, 18 Oct 2026 12:12
56 lines
3680 bytes
On 2026-10-18 13:22, David Brown wrote:
> On 17/10/2026 13:34, bart wrote:
>> [...]
>>    char (*(*x())[])()
>> [...]
> 
> Putting that example in cdecl gives :
> 
> "declare x as function returning pointer to array of pointer to function 
> returning char"

There's different things here with the C-declaration.
* Complexity of expression; as you say below this can be alleviated by
    structuring with "subtypes" and 'typedef'.
* Cryptic syntax with many (spurious but in "C" necessary) parenthesis.
* Mixed/mangled order of component concerning its logical structure.

The 'cdecl' tool helps with point 2 and 3. - So I consider it to be
quite useful! (Although I have to admit that I've never used it myself
in practice because (for my code) I try to not compose overly complex
type definitions; and when it gets complex point 1 applies.) Especially
if you have to work with third-party code it can spare you some time,
though.

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

I assume you're here commenting on some of bart's adopted syntactical
decisions.

FWIW; why I prefer some other language design decisions is exactly that
they use syntaxes with such keywords. They typically reduce the number
of parentheses and other "graph" characters thereby reducing the effect
of code appearing quickly more cryptic than necessary, they make the
definition more clear and better readable (IMO). Keeping (in addition)
the logical order of its components also helps IMO to easier understand
the declaration construct.

To be frank, it's beyond me why anyone wouldn't admire such consistent
declaration syntaxes. (And if bart has adopted those principles that's
certainly not a bad thing. YMMV.)

> 
> If you want complex types in a programming language, make them out of 
> simpler, named types that express what you are trying to achieve.  I 
> think any decent typed programming language will have a way to do this - 
> for C, "typedef" is your friend here.

Yes. This is what we can do about the "complexity" aspect of the topic.

Janis

> [snip]
Technical Details
Message-ID: <11b2d46$3pvda$5@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>

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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Sun, 18 Oct 2026 14:12:54 +0200
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <11b2d46$3pvda$5@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Oct 2026 12:12:55 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3997098"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+7EK5sXItN5fike0KyGRxH"; posting-host="413ca35758bf2644217f2957a34a3916"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6q2uXE2nM2KI1PaQyBJAH6d6GBQ= sha256:udwyR7P8jl+3YaJuy4RkN1wHZhJ83PSqp0R//M2bMBI=
	sha1:djuTwswAKLiFnKtePM5MInyKAq8= sha256:ZtR3qCyyvEfZ2WtdOrgwSC1HP4+uQkj+i0zc0GzuFGw=
In-Reply-To: <11b2a6d$131h6$1@dont-email.me>
Content-Language: en-US