Article View: comp.lang.c
Article #424Re: Taming The Switch-Statement
From: Dan Cross
Date: Thu, 15 Oct 2026 14:37
Date: Thu, 15 Oct 2026 14:37
48 lines
2783 bytes
2783 bytes
In article <86bj8vqhtl.fsf@linuxsc.com>, Tim Rentsch <tr.17687@z991.linuxsc.com> wrote: >cross@spitfire.i.gajendra.net (Dan Cross) writes: > >> In article <11aoqa9$1rgda$1@dont-email.me>, bart <bc@freeuk.com> wrote: >> >>> On 14/10/2026 20:30, Dan Cross wrote: >>> [snip more of the same already hashed and rehashed ad naseum] >>> >>> As for multiple nested loops, this will fix that too, that's great. We >>> just require some real examples of that being needed! >> >> Here's a pretty terrible way to write part of a lexical >> analyzer. I just typed this in an hour or so ago. >> >> [200+ lines of code] > >This code provides an excellent example of why multi-level breaks >should not be added to C. It is probably true that this snippet is a good example of how labeled break/continue can be abused. The code is awful. However, the current C2y draft standard already has labeled break and continue; the probability that it won't make it into the next standard revision is low. Moreover, other languages have had it for years (in some cases, decades) at this point and the sky has not fallen. One bad example, meant only to illustrate a couple of use cases, should not be used as evidence either way to draw a general conclusion about, well, anything. >The code would be easier to understand >if all the 'break <label>;' lines were replaced with one of 'goto >TOKEN_COMPLETE;' or 'goto COMMENT_COMPLETE;', as appropriate, >and with the loop labels being removed and the two new labels put >in at the appropriate places. Whenever one says that, "the code would be easier to understand" one is necessarily making a subjective judgement. In this case, _I_ think that code would be far easier to understand written in an entirely different way that didn't reach for `goto` at all. - Dan C.
Technical Details
Message-ID:
<11aqoep$82u$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> <11aoqa9$1rgda$1@dont-email.me> <11apa4b$kv$1@reader2.panix.com> <86bj8vqhtl.fsf@linuxsc.com>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: Thu, 15 Oct 2026 14:37:13 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11aqoep$82u$1@reader2.panix.com> References: <119qf6l$2rmg3$1@dont-email.me> <11aoqa9$1rgda$1@dont-email.me> <11apa4b$kv$1@reader2.panix.com> <86bj8vqhtl.fsf@linuxsc.com> Injection-Date: Thu, 15 Oct 2026 14:37:13 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="8286"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)