Deutsch English Français Italiano |
<vu5afk$23f8f$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: James Kuyper <jameskuyper@alumni.caltech.edu> Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Mon, 21 Apr 2025 07:34:11 -0400 Organization: A noiseless patient Spider Lines: 58 Message-ID: <vu5afk$23f8f$1@dont-email.me> References: <vspbjh$8dvd$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> <hxOMP.335104$j2D.272394@fx09.iad> <20250419092849.652@kylheku.com> <vu0t5m$22rjp$1@dont-email.me> <vu0v2n$22n7b$4@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 21 Apr 2025 13:34:15 +0200 (CEST) Injection-Info: dont-email.me; posting-host="cf3297d0520b68c9c0a7bce9b0e581c6"; logging-data="2211087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ADfWp/Cj0mhjWjR8nUQq3ruVJ3Gbo2yo=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:DCo77oq9IQwsvEr8dJJZWy3oFLM= Content-Language: en-US In-Reply-To: <vu0v2n$22n7b$4@dont-email.me> bart <bc@freeuk.com> wrote: > On 19/04/2025 20:22, James Kuyper wrote: .... >> I wasn't talking about him finding the tools problematic. I was talking >> aobut him find it difficult to ensure that the expressions are not >> arbitrary unrelated expressions, but are in fact correctly related >> expressions. If you cannot ensure that A, B, and C have the correct >> relationship to make for(A; B; C) work as needed, then you also lack to >> ability to make sure that the expressions in {A; B; C:} work together as >> needed, and that ability is fundamental to computer programming. > > In other words, the feature is dumb. The feature allows you to pack all of the loop management stuff together where it's easy to check and think about. It can be misused, by putting together stuff that has nothing to do with loop management, just as an assignment statement can be misused by writing, for instance annual_salary = current_income + age; > The compiler cannot do any checking: for (i=0; i<n; ++n) is fine. The compiler cannot tell you what's wrong with that assignment statement, either. > Even in BASIC, if I do this: > > for i=1 to n > next n> > it will say that n does not match. And here it is optional; in C that > part is necessary. It's been a while since I've written basic, but looking at that syntax I believe it would be equally feasible to write for i=start_year to months_per_year Can BASIC protect you from misusing it's for statement by putting in the wrong expressions for the start and end of the loop? Then why would expect C's loop construct to do any better? > But, you have a bizarre take on this: if somebody calls it out, then > rather than agree with them, you will personally insult the person who > said it, and suggest that if they are incapable of such a simple check, > then they shouldn't be coding. How can I respond by agreeing with an incorrect assessment? And the insults are the consequence of your endlessly successful search to find new ways to misunderstand C. > The fact is that people make typos (obviously, not you or JP or SL or I make typos all the time. I love language features that let me catch my typos. That's one reason why I like languages that provide features like "for each employee in employee_list", but I see little advantage to a for statement limited in the fashion you desire. It's easily emulated by the more flexible for-statement that also allows me to do many other things as well.