Sujet : Re: Loops (was Re: do { quit; } else { })
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 18. Apr 2025, 23:27:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtujko$3uida$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
User-Agent : Mozilla Thunderbird
On 18/04/2025 19:10, James Kuyper wrote:
On 16.04.2025 13:01, bart wrote:
...
Unlike C's for, which is just a gimmick where you bundle three
potentially unrelated expressions and hope for the best.
If all you can do is "hope for the best", you're doing it wrong. It's
your job to ensure that they are not arbitrary unrelated expressions,
but correctly related expressions, and that's no different from your
responsibility for all of the other expressions that make up your
program.
If you find that problematic, you shouldn't be programming in
any language, but certainly not in C.
I see it didn't take you long to get to the personal insult. What is it with this group?
My remarks were about what C call's 'for', being a very low level construct, even at this level of language.
The language will not check that those three parts are correct for the loop you are trying to express, because there is no way for it to know that.
So that if you do make a mistake, it can't help you, unless it fails incidentally for some other reason. This is where you cannot rely on the compiler, and hence my remark.
See recent posts by JP where they used "<=" instead of "<", and by LP where they used "N" instead of "N-1".
So, yes, I think that is problematic, and the fault is with the language. This stuff isn't not hard to get right; even BASIC manages to FOR-loops properly.
It's a bit of a cheek to suggest that if people tend to make more compiler-undetectable errors because C's FOR is dumb, that they should give up programming.