Article View: comp.lang.c
Article #552Re: Taming The Switch-Statement
From: Janis Papanagnou
Date: Mon, 19 Oct 2026 14:03
Date: Mon, 19 Oct 2026 14:03
64 lines
4355 bytes
4355 bytes
On 2026-10-19 15:46, David Brown wrote: > On 19/10/2026 15:16, Janis Papanagnou wrote: >> [...] >> > 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. Yes, that can be regularly observed, and not only in case of the declaration but generally; with known building blocks you can construct arbitrary complex expressions incrementally, so it might not appear as a problem at the time one writes it. But then parsing complex expressions - say, if that code is from another person or source - it gets difficult. (Topic reminds me Regexp expressions.) But also program composition in general is sometimes following an incremental growing process. Structuring is the key. > 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. Give a name to the function pointer type that > reflects the usage (/not/ a name that reflects the definition), and > build up from there. I fully agree. Where I obviously have a different valuation is that I saw in other languages' contexts that there's less issues with this topic. > > 2. Being able to declare variables and functions with different types in > the same declaration. Very occasionally, I find it convenient to > declare more than one variable at once - "int a, b, c;". It is rare in > my code - generally it is one variable with an initialiser (and perhaps > a comment) at a time. Absolutely the same for me. > But it is - IMHO - a bad thing that you can write > "int a, xs[20], *p, (*f)(void);" in one declaration. I agree. - But as opposed to other posters that's no serious problem; "if it hurts, just don't do it". > > Both of these are overcome by simply not writing code that way. (I should have read your post to the end before my previous statement.) > Obviously that is easy to achieve in my own code, but other people may > use a different style. And that's why companies instantiate coding standards. Janis
Technical Details
Message-ID:
<11b57vh$1kr9u$3@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-mailReferences:
<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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Mon, 19 Oct 2026 16:03:29 +0200 Organization: A noiseless patient Spider Lines: 64 Message-ID: <11b57vh$1kr9u$3@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 14:03:30 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1731902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IYhj/42t0aZgDWxcMhJsb"; posting-host="9a1787de1638a6d9f83c958712c1b12a" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:woUlkKwITB7lMlUdAFV829K3Qp4= sha256:DuuU2T4pJZGmqI04VrAhJdKQ8fWRtWn7x1pbS1vreYM= sha1:Ivm4eFwZ/2d5Uy3lOSy8AoSZBD0= sha256:oFuKETmcz06o5geB1Z+jlL/2Mzn7MguIBD9vCNNYK/M= Content-Language: en-US In-Reply-To: <11b56uo$1q18k$5@dont-email.me>