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: Sat, 19 Apr 2025 12:54:15 -0700 Organization: None to speak of Lines: 61 Message-ID: <8734e4nd08.fsf@nosuchdomain.example.com> References: <20250413072027.219@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 19 Apr 2025 21:54:21 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b62a019a496a9456e80ffe1b61d2a7b5"; logging-data="2214692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YqlpKweKTWCSr6aFRmfd2" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:ZmfQv9jNCswE/mjKgD6JGlXhDAk= sha1:E2EbhJSesHP/9VXvHl9Syl0j0y8= Xref: csiph.com comp.lang.c:392723 bart writes: [...] > I don't understand why you're happy using a crippled looping > mechanism, that is a PITA to use for the majority of iterating loops, > just so you have that flexibility for the whacky loops that are in the > minority, most of which can be trivially expressed with 'while'. [...] I agree. You don't understand. What confuses me is your complete lack of interest in trying to understand. Many of us are happy using C's for loop because we don't consider it to be crippled. It is not a PITA to use it for the majority of iterating loops; we just use a very common coding pattern like for (int i = 0; i < N; i ++) { // ... } We can write "i --" if we want the loop to run in reverse, or "i += 3" if that's what we want. Mistakes are possible, but rare. Mistakes are more likely in code fragments in Usenet articles than in real-world code. Sure, I could use a while loop rather than, say : for (node *ptr = head; node != NULL; node = node=>next) { // ... } but thanks to C's flexible for loop, I don't have to. And no, I don't consider this loop "whacky". We know that you *don't like* any of this, and that's fine, but you cannot reasonably disagree with the observed fact that many C programmers are able to use C-style for loops effectively. If a future edition of the C standard added a for loop of the kind you prefer, Id be fine with that, and I'd probably use it. Perhaps, off the top of my head something like for ((int i; first; last [; increment])) { // ... } or for (int i in first ... last [step increment]) { // .. } But that's not likely to happen, because (a) as far as I know nobody has proposed it, and (b) **it's not needed**. You act as if you think we're all either lying or stupid for not agreeing with your personal preferences. We're not. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */