Article View: comp.lang.c
Article #558Re: Taming The Switch-Statement
From: David Brown
Date: Mon, 19 Oct 2026 16:31
Date: Mon, 19 Oct 2026 16:31
34 lines
2673 bytes
2673 bytes
On 19/10/2026 16:35, Dan Cross wrote: > In article <11b4smj$1vt4q$1@kst.eternal-september.org>, > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >> The odd scoping rules for labels don't bother me either. They mean >> you can't have two loops or switch statements with the same name in >> the same function. I can barely imagine that being inconvenient. > > An issue is that one might generate such a named loop with a > macro. I can imagine that being useful for `XIMPL` type > constructs, but C's macros are unusually weak, and C doesn't > have something like `(GENSYM)` in Lisp, so you've got to plumb > the loop name through the macro invocation: mildly annoying, but > not too bad. Hopefully the N3658 fix for that will be in C2y. <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3658.htm> That will also let people - for better or worse - write things like: #define For Loop_label: for #define While Loop_label: while #define Switch Switch_label #define Break_Loop break Loop_label #define Break_Switch break Switch_label > > Then again, if a programmer is abusing macros like that to > generate named loops multiple times in the same function, > then perhaps the program needs a re-think, ximpl or no. > > - Dan C. >
Technical Details
Message-ID:
<11b5gl6$27la0$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-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <20261018223859.000031d3@yahoo.com> <11b4n4s$1q18k$1@dont-email.me> <11b4smj$1vt4q$1@kst.eternal-september.org> <11b59qq$7hk$1@reader2.panix.com>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: Mon, 19 Oct 2026 18:31:34 +0200 Organization: A noiseless patient Spider Lines: 34 Message-ID: <11b5gl6$27la0$1@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <20261018223859.000031d3@yahoo.com> <11b4n4s$1q18k$1@dont-email.me> <11b4smj$1vt4q$1@kst.eternal-september.org> <11b59qq$7hk$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 19 Oct 2026 16:31:35 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2348352"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EtLXErr6RNHK1BNk9HLkomfK5laQANSg="; posting-host="f8e69aeaa618e660247a66e432a03539" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:4VF89ohUgYI3v5G3tHL/SF3tnKE= sha256:Lo0Bu/jyuQ1dVoRe4WZyIs5MQvsxqwA0PGvWHeajy5Y= sha1:fkRyF2TCBP8732iGMjm7Jy4awrg= sha256:9nyr3pQM/W+2gJUuRxx0YzAUs8Nv9Ykl1RcKixmshFg= Content-Language: en-GB In-Reply-To: <11b59qq$7hk$1@reader2.panix.com>