| Deutsch English Français Italiano |
|
<87ldruv65j.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Sun, 20 Apr 2025 15:07:20 -0700
Organization: None to speak of
Lines: 32
Message-ID: <87ldruv65j.fsf@nosuchdomain.example.com>
References: <vspbjh$8dvd$1@dont-email.me> <vtf7fe$1qtpg$1@dont-email.me>
<vtgfuf$31ug1$1@dont-email.me> <20250413072027.219@kylheku.com>
<vtgpce$39229$1@dont-email.me> <vti2ki$g23v$1@dont-email.me>
<vtin99$vu24$1@dont-email.me> <vtiuf0$18au8$1@dont-email.me>
<vtj97r$1i3v3$1@dont-email.me> <vtl166$36p6b$1@dont-email.me>
<vtlcg0$3f46a$2@dont-email.me> <vtnekn$1fogv$1@dont-email.me>
<vto2mb$20c4n$1@dont-email.me> <vtu4i5$3hteg$1@dont-email.me>
<vtujko$3uida$1@dont-email.me> <vtvfop$rf2p$1@dont-email.me>
<vtvto2$15otp$1@dont-email.me> <vu01k7$1bfv2$1@dont-email.me>
<vu0720$1dva7$1@dont-email.me> <vu2hmg$3jn88$1@dont-email.me>
<vu2mkc$3noft$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 21 Apr 2025 00:07:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9df2d817d671536e75ba887619a4c13a";
logging-data="730752"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nQvukqeiYZ5zgbuzFRcVM"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:+QmLMu7sa9v9LCUBctb4kzbK9hs=
sha1:M7JbK7UPIm6YlusMcke//yAPzNE=
bart <bc@freeuk.com> writes:
[...]
> Actually here's a example from sqlite3.c:
>
> for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){
> sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
> }
>
> And this is how you might be forced to write it instead:
>
> p=sqliteHashFirst(&pSchema->trigHash);
> while (p) {
> sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
> p=sqliteHashNext(p);
> }
>
> Yes, it's spread over two more lines, but so what? It's much clearer:
> the initialisation is done once and then it's out of the way. Setting
> p to the next value is now physically written after the body.
[...]
I understand and completely accept that you find the while loop
clearer, and I have no interest in changing your mind.
I find the for loop clearer. I won't speak for anyone else, but I
suspect a lot of C programmers would also find the for loop clearer.
I don't believe you've ever acknowledged that.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */