๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #493

Re: Taming The Switch-Statement

#493
From: David Brown
Date: Sun, 18 Oct 2026 11:22
81 lines
4577 bytes
On 17/10/2026 13:34, bart wrote:
> On 17/10/2026 04:19, Dan Cross wrote:
>> In article <11auad0$3no1k$1@dont-email.me>, bartย  <bc@freeuk.com> wrote:
> 
>>> Those are considered more productive.
>>
>> ...and you think that's because of the syntax, and not the high
>> level nature of those languages?
> 
> It's a combination.
> 
>> Yes, the syntax is pretty gnarly; Dennis Ritchie even said as
>> much.ย  Fixed in Go and Rust, but also, I doubt you've ever in
>> your life had a variable of type array of array of length 8 of
>> a pointer to a pointer to a function returning an array of
>> pointers to char.ย  Finding the most ridiculous example you can
>> is not really evidence of anything besides your weird obsession
> 
> That was the first one I saw online next to a quote from K&R and I 
> assumed it was from the book. In fact the example from the book is this:
> 
>  ย  char (*(*x())[])()
> 
> I've no idea what the means either. The point is not that the examples 
> are ridiculous, but that they are hard to convert to and from LTR form 
> which is how we think. With LTR syntax it becomes utterly trivial to 
> read or write them, no matter how complex.
> 
> (There's a tool called CDECL that translates types from C syntax to LTR 
> English or vice versa. It calls the C versions 'gibberish'. This is a 
> real thing!)
> 

Putting that example in cdecl gives :

"declare x as function returning pointer to array of pointer to function 
returning char"

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.

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.

(And do /not/ reply by bringing up examples you have cherry-picked from 
code you have found, as though it was my fault they wrote 
incomprehensible code.)


> 
>> with finding abstruse corner cases and holding them up as
>> reasons to dislike C.
> 
> The first example I gave was the simplest form of function pointer, 
> where the syntax is 'void(*)(void)'. Hardly a corner case, and it 
> rapidly goes downhill.

Name the types at the point where they are clear, and build them up from 
there.

	typedef void (*fp_void)(void);



> 
> If meeting C for the first time, that does not bode well. If the 
> designers did not care about this, that does not inspire confidence in 
> the rest of the language.

C is not, and has never claimed to be, a beginner-friendly language.  It 
is designed to be efficient while remaining quite a small language, 
which means that there are parts that are harder to use correctly, 
details that are important to understand, and it has plenty of scope to 
write code that is unclear.  It works well for responsible programmers 
who learn the language and code carefully - but you have to learn more 
before you can understand and use it than, say, BASIC or Python.

Technical Details
Message-ID: <11b2a6d$131h6$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>

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: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Sun, 18 Oct 2026 13:22:52 +0200
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <11b2a6d$131h6$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Oct 2026 11:22:54 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1148454"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX185oPCY2VmTB6pNsxiVXcXiP2ni6vISXSw="; posting-host="a272f2752d0a4376a695806f42b83d2a"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/BcuSP3jJKK19ee031vv9OjE2vU= sha256:xFu1l/faX1z65sZtZtsKaeSIzfnNC0h4bCUdYeq9hrg=
	sha1:VYFK5YCOUkIbh24fNM5JdxGIz6E= sha256:3PMUpWMgvbnvvPrmudm1lURaRKadZNJTBri0/mCJva0=
In-Reply-To: <11avmfb$55rt$1@dont-email.me>
Content-Language: en-GB