🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #450

Re: Taming The Switch-Statement

#450
From: Waldek Hebisch
Date: Fri, 16 Oct 2026 15:24
23 lines
2426 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> wrote:
> On Tue, 13 Oct 2026 07:23:40 -0000 (UTC), Waldek Hebisch wrote:
> 
>> So what those counts indicate: majority of loops is simple, that is
>> have no early exit. Vast majority of early exits is done via
>> 'return'.
> 
> My experience in my own C code is quite the opposite. Lots of loops
> have exits in the middle, leading me to use forms like “for (;;)”. I
> also try to avoid putting “return” anywhere other than the end of a
> function, to make it easier to see the flow of control.

Well, usually there is a lot of loops.  Those with exit in the
middle are still significant.

Concernig 'return', having it in place where all work inside function
is done help me to see flow control and avoids complications.  In
case of search functions it means return from the middle of the loop.
IMO possible alternatives like flag variables or break and retrun
after loop are worse.

-- 
                              Waldek Hebisch
Technical Details
Message-ID: <11atfif$38b7p$1@paganini.bofh.team>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <20261010230355.00005189@yahoo.com> <864iesjx6e.fsf@linuxsc.com> <11afvqt$2kloc$1@dont-email.me> <11ag37o$2ln0a$1@dont-email.me> <11agbsh$2pbk7$1@dont-email.me> <11aggaq$2qqh9$1@dont-email.me> <11agils$2s3tg$1@dont-email.me> <11agv1t$30q22$2@kst.eternal-september.org> <20261012220256.00003d07@yahoo.com> <11ajb95$3t8jj$1@dont-email.me> <20261012223144.00000f95@yahoo.com> <11akm9q$29tpl$1@paganini.bofh.team> <11am99u$ul56$2@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!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Fri, 16 Oct 2026 15:24:01 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11atfif$38b7p$1@paganini.bofh.team>
References: <119qf6l$2rmg3$1@dont-email.me>   <20261010230355.00005189@yahoo.com> <864iesjx6e.fsf@linuxsc.com> <11afvqt$2kloc$1@dont-email.me> <11ag37o$2ln0a$1@dont-email.me> <11agbsh$2pbk7$1@dont-email.me> <11aggaq$2qqh9$1@dont-email.me> <11agils$2s3tg$1@dont-email.me> <11agv1t$30q22$2@kst.eternal-september.org> <20261012220256.00003d07@yahoo.com> <11ajb95$3t8jj$1@dont-email.me> <20261012223144.00000f95@yahoo.com> <11akm9q$29tpl$1@paganini.bofh.team> <11am99u$ul56$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 16 Oct 2026 15:24:01 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3419385"; mail-complaints-to="usenet@bofh.team"; posting-host="d028f9ad2fa2c51f22dbfed0d81d7daf"; posting-account="69e66f1681224ab92235b464ce7a90b6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Postfilter: Postfilter-NG 2026.10.2