Article View: comp.lang.c
Article #622Re: Taming The Switch-Statement
From: Dan Cross
Date: Wed, 21 Oct 2026 00:56
Date: Wed, 21 Oct 2026 00:56
81 lines
3654 bytes
3654 bytes
In article <11b8qqg$3ejlp$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>On 20/10/2026 22:44, Dan Cross wrote:
>> In article <11b8j17$3btus$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>> On 20/10/2026 20:24, Dan Cross wrote:
>>>> In article <11b7k22$2v8e5$1@dont-email.me>, bart <bc@freeuk.com> wrote:
>>>
>>>> The point is that the name you chose is meaningless to anyone
>>>> other than you. What's a PCL? Phase Control Line? Printer
>>>> Command Language? Photon Compressor Loop?
>>>
>>> Within the context of that application then it would be clear. You're
>>> just being overly hostile.
>>
>> Not really. You are, I presume, posting that code to try and
>> make some kind of point about how "readable" it is. But it's
>> not readable unless you already know what it does.
>
>What it does not relevant. This is simply defining an array of T. But
>because T happens to be a function pointer, DB insists that an alias
>must be created, and a new name invented.
>
>Why? Probably because in C, the syntax for function pointers gets hairy.
I dunno; your syntax didn't seem any clearer to me.
>> On the other hand, the code David posted _is_ readable, because
>> it uses the language to encode domain-specific information into
>> type names.
>
>Maybe we should create aliases for function signatures more often then,
>then we can encode that extra info.
>
>So that instead of, for example:
>
> void SomeFunc(int x, int y) {printf("%d %d\n", x, y);}
>
>you do:
>
> typedef void Take2Ints(int x, int y);
>
> Take2Ints SomeFunc {printf("%d %d\n", x, y);}
>
>If you have a suite of functions sharing the signature, then it might be
>a good idea. But funnily enough, you never see this being done.
Yeah, you really don't get it.
You remind me of the guy at Google who objected to importing the
`std::` namespace in C++ into the default scope; "oh, so what;
we should all write ::std::whatever::foo<::std::blah>(...)?!" as
if finding the most stupidly extreme example was somehow a
useful technical argument. He also spent all his time on
mailing lists arguing about how everybody else Got It Wrong. He
got fired a few months later.
>(I don't know if this is legal C; but it works fine with my compiler:
>
> c:\m>type fred.c
> #include <stdio.h>
>
> typedef void Take2Ints(int x, int y);
>
> Take2Ints SomeFunc{printf("%d %d\n", x, y);}
>
> int main(void) { SomeFunc(10, 20); }
>
> c:\m>bcc -r -q fred
> 10 20
>)
Yeah, I gues running it through `gcc` is a really heavy lift.
<eyeroll>
>> Yeah, you really just don't get it.
>
>One of us doesn't get it.
I'm glad you can admit it.
- Dan C.
Technical Details
Message-ID:
<11b92j1$dhb$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11b8j17$3btus$1@dont-email.me> <11b8nc4$9aq$1@reader2.panix.com> <11b8qqg$3ejlp$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!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Wed, 21 Oct 2026 00:56:01 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11b92j1$dhb$1@reader2.panix.com> References: <119qf6l$2rmg3$1@dont-email.me> <11b8j17$3btus$1@dont-email.me> <11b8nc4$9aq$1@reader2.panix.com> <11b8qqg$3ejlp$1@dont-email.me> Injection-Date: Wed, 21 Oct 2026 00:56:01 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="13867"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)