Deutsch   English   Français   Italiano  
<20250420200823.908@kylheku.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: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Mon, 21 Apr 2025 03:16:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20250420200823.908@kylheku.com>
References: <vspbjh$8dvd$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> <vu38da$735n$1@dont-email.me>
 <vu3j7s$g755$1@dont-email.me> <87ecxmv4t4.fsf@nosuchdomain.example.com>
 <vu401g$reom$1@dont-email.me>
Injection-Date: Mon, 21 Apr 2025 05:16:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c13f5017c98192b6c07a0b629837b649";
	logging-data="1393164"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18a6yrbLa/kF2CtFS0DK6tBzo36GBkj8zE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:aWGIX/fwa0T6PG8jms6aE9UC7rQ=

On 2025-04-20, bart <bc@freeuk.com> wrote:
> But the thing is, once you split it into multiple lines, then there is 
> little advantage over using a regular 'while' loop:

The advantage may be little, but there is some.

>        p = sqliteHashFirst(&pSchema->trigHash);
>        while (p != NULL)
>        {
>            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
>            p = sqliteHashNext(p) )
>        }

- In a while loop, if you "continue", it will jump to the top of
  the loop, without executing the step.

- The loop controls are not gathered in one place.

- Because they are not gathered in one place, not only is it less
  readable, but we cannot use while write a macro such as:

     for_sqlite_hash (p, &pSchema->trigHash) {
       if (some_condition_over(p))
         continue; // doesn't stupidly repeat for the same p!
     }

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca