🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #580

Re: Taming The Switch-Statement

#580
From: Bob Duff
Date: Mon, 19 Oct 2026 23:38
40 lines
2914 bytes
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Names used for loops have a lighter-weight syntax:
>
>     LOOP_NAME:
>     while condition loop
>         -- ...
>     end loop;

That's a syntax error. In Ada, if you put a loop name at the top of the
loop, you are required to repeat it at the bottom, like this:

    LOOP_NAME: while condition loop
        ...
    end loop LOOP_NAME;

If there's an "exit LOOP_NAME;" in there, it's pretty clear which
loop it's jumping out of, AND where it's jumping to.

> I can't think of a better syntax for loop names than "NAME:" (used
> by several other languages), but in C that syntax is already
> taken for goto labels.

Agreed.

But in current C (before adding the named-loop feature),
and in Ada, and in many other languages, a label serves
as a warning: One or more gotos jump here. That's useful
information.

This new feature of C seems to lose that benefit, which
is unfortunate. But I think the "while LOOP_NAME..."
syntax is less readable than "LOOP_NAME: while...",
as you said.

So if it were up to me, I wouldn't add named loops to C in
either proposed syntax. The "goto" is good enough for
jumping out of nested loops.

- Bob
Technical Details
Message-ID: <wccecdl8dmp.fsf@shell02.theworld.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder9.news.weretis.net!xmission!usenet.csail.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11ae56o$cjlv$4@dont-email.me> <20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me> <11aeee0$24k8m$1@kst.eternal-september.org> <11aer17$286ml$2@dont-email.me> <11aeusp$29hmu$2@kst.eternal-september.org> <86mrsdpcgp.fsf@linuxsc.com> <11au6pr$3mdne$1@kst.eternal-september.org> <11auc0s$206gh$3@dont-email.me> <11b285v$121v2$2@dont-email.me> <11b293j$12jfa$1@dont-email.me> <11b2cuh$141vj$1@dont-email.me> <11b2eck$3pvd9$1@dont-email.me> <20261018171339.00005308@yahoo.com> <11b2mf1$16mof$2@dont-email.me> <20261018181623.00007978@yahoo.com> <11b347h$1cn63$1@dont-email.me> <20261018223859.000031d3@yahoo.com> <11b4n4s$1q18k$1@dont-email.me> <11b4smj$1vt4q$1@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder9.news.weretis.net!xmission!usenet.csail.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail
From: Bob Duff <invalid@invalid.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Mon, 19 Oct 2026 19:38:38 -0400
Organization: The World Public Access UNIX, Brookline, MA
Lines: 40
Message-ID: <wccecdl8dmp.fsf@shell02.theworld.com>
References: <119qf6l$2rmg3$1@dont-email.me> <11ae56o$cjlv$4@dont-email.me>
	<20261010230355.00005189@yahoo.com> <11ae7eb$cjlv$6@dont-email.me>
	<11aeee0$24k8m$1@kst.eternal-september.org>
	<11aer17$286ml$2@dont-email.me>
	<11aeusp$29hmu$2@kst.eternal-september.org>
	<86mrsdpcgp.fsf@linuxsc.com>
	<11au6pr$3mdne$1@kst.eternal-september.org>
	<11auc0s$206gh$3@dont-email.me> <11b285v$121v2$2@dont-email.me>
	<11b293j$12jfa$1@dont-email.me> <11b2cuh$141vj$1@dont-email.me>
	<11b2eck$3pvd9$1@dont-email.me> <20261018171339.00005308@yahoo.com>
	<11b2mf1$16mof$2@dont-email.me> <20261018181623.00007978@yahoo.com>
	<11b347h$1cn63$1@dont-email.me> <20261018223859.000031d3@yahoo.com>
	<11b4n4s$1q18k$1@dont-email.me>
	<11b4smj$1vt4q$1@kst.eternal-september.org>
NNTP-Posting-Host: shell02.theworld.com
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: pcls7.std.com 1792453118 23325 192.74.137.72 (19 Oct 2026 23:38:38 GMT)
X-Complaints-To: abuse@TheWorld.com
NNTP-Posting-Date: Mon, 19 Oct 2026 23:38:38 +0000 (UTC)
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock: sha1:RSjZXe9/e0erASsw92sZSbCg4HY=