Path: ...!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: Mon, 21 Apr 2025 18:22:09 -0700 Organization: None to speak of Lines: 64 Message-ID: <87sem1yoqm.fsf@nosuchdomain.example.com> References: <874iyh153g.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Tue, 22 Apr 2025 03:22:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e72db596057d83171632e4a496618536"; logging-data="3552146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zE16iS4SB2ekpkvXpLEv4" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Bp2EdDpRjLHSV7b6WX2sGxiDei0= sha1:RWkV+PXMlZCCcA+ks5ORypUMX04= Bytes: 4162 bart writes: > On 22/04/2025 00:12, Keith Thompson wrote: >> bart writes: >>> On 21/04/2025 22:06, Waldek Hebisch wrote: >>>> bart wrote: >>> >>> t iteration goes over all elements in the hash table. >>>> BTW2: When looking at 'for' loop you are supposed to see pattern, >>>> without need to track all steps. >>> >>> That's one of the disadvantages of using the same, often >>> /inappropriate/ keyword for every kind of pattern. >> You think it's inappropriate. >> Would your objections go away if a different keyword were used? > > I already said that I would have prefered if 'while' was used. > > Then either 'for' wasn't used, or was used for the kind of for-loop > that is common in other languages. So you wouldn't mind if C had both `while (expr)` and `while (expr1; expr2; expr3)`, with the latter having the semantics of C's current for loop? But that doesn't answer my question. You'd prefer "while", but would using "while" rather than "for" resolve your objections? >> *You* find it much cleaner and simpler. I don't. What makes you right >> and everyone else wrong? > > This is an interesting point: too much stuff on one line is usually > frowned upon: multiple statements, multiple variables being declared > etc. > > But when it's a for-loop, then apparently anything goes. For some, sure. For others, no. >> All three would be IMHO clearer if each of the three clauses were on a >> separate line. The fact that you can write a badly formatted C-style >> for loop is not an argument against C-style for loops. > > Complex loops are nearly always badly formatted and written on one > line. Nobody cares. As you've demonstrated. I have demonstrated no such thing. I am not as bothered by long for loops with odd line breaks (or none) as you think I should be, but I have clearly expressed my personal preference for putting each of the three clauses on its own line if they're too long to reasonably fit on one line. One more thing. You often snip context when posting a followup. That's fine if you're not responding to everything, but I would greatly appreciate it if you would mark your deletions. For example, in my post to which you replied, I discussed at some length how I like to split for loops if they're too long. You snipped that discussion *and then* insinuated that I don't care about complex loops written on one line. Please stop doing things like that. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */