Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson 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: <20250413072027.219@kylheku.com> 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= Xref: csiph.com comp.lang.c:392762 bart 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 */