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: Mon, 21 Apr 2025 14:21:30 -0700 Organization: None to speak of Lines: 66 Message-ID: <87o6wp1a91.fsf@nosuchdomain.example.com> References: <20250419092849.652@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 21 Apr 2025 23:21:34 +0200 (CEST) Injection-Info: dont-email.me; posting-host="9df2d817d671536e75ba887619a4c13a"; logging-data="3230107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2zFEPIVYI7mCi95Cprfdw" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:K97fu43MBuHpHggKGriMGYQVyrI= sha1:kh5RF8/VRE1nNhvKJb2zaQ9+pQs= Xref: csiph.com comp.lang.c:392785 bart writes: [...] > I don't now think think there is any argument that will make any > difference. People here genuinely think that writing: > > for (ch = 0; ch <= 255; ++ch) > > is far superior to this 'primitive' version: > > do ch = 0, 255 > > No amount of discussion or arguments will make them change their minds. You misunderstand. The idea that the C-style loop is "far superior" is your invention. Your attempts to summarize the opinions of people you so strongly disagree with have largely been unsuccessful. Perhaps my attempts to summarize your opinions would also be unsuccessful, though I *think* I understand your opinions better than you understand mine. If I'm programming in C, the C-style for loop is better because it exists and doesn't fail with a syntax error. If I'm programming in a language (Fortran?) that provides the second form but not the first, the second form is obviously better for exactly the same reason. I think that really is 90+% of what programmers think about when choosing how to write a loop: What does the language provide? Most programmers would consider complaining more that briefly that they dislike a given construct to be a waste of time. Sure, griping about programming languages is common, but less common that just getting on with the job of using the language. Yes, the Fortran style loop is shorter than the C-style loop. Few programmers care as much as you do how many characters or tokens are needed for a given construct. [...] > Apparently, the C form is superior because that construct can also be > used to conveniently express link-list traversal, and a lot more. I don't know that I'd use the word "superior", but it's certainly an advantage. > Even the idea of having *two* kinds of loop, one as it works now, and > one more streamlined, was not acceptable: too much 'overloading' of > the language. Like any idea, some people would like it, some would accept it, and some would dislike it. It is certainly the case that the kind of for loop you'd prefer is not *necessary* in C, since everything it can do can be done using the existing C-style for loop (perhaps with some trickery to avoid overflow at the upper or lower bound). Do not infer from that that I think a language should only provide "necessary" features. C-style for loops have been used successfully for decades, and have been adopted by other languages (including bash, which isn't particularly C-like). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */