Sujet : Re: Loops (was Re: do { quit; } else { })
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 22. Apr 2025, 02:22:09
Autres entêtes
Organisation : None to speak of
Message-ID : <87sem1yoqm.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
On 22/04/2025 00:12, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
On 21/04/2025 22:06, Waldek Hebisch wrote:
bart <bc@freeuk.com> 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.comvoid Void(void) { Void(); } /* The recursive call of the void */