Liste des Groupes | Revenir à cl c |
On 14.04.2025 17:22, bart wrote:I can't grok that.On 14/04/2025 13:18, Janis Papanagnou wrote:Not the least.(While there's some "C" stuff in here it contains a lot of non-"C">
samples for comparison. So [OT]-sensible folks may want to skip this
post.)[...]>
I'm not saying there's anything wrong with it. The point was that an A
to B loop existed in the 1950s; C came out in the 1970s!
>[...][...]
>which of course would be written with a 'while'>
>
int i = a;
while (i <= b) f(i++)
That would be a poor use of 'while'.
And bizarre, to use 'while' forI was merely trying to provide some options to address your dislike.
iteration, but 'for' for loops that are best written as while!
>Well, our opinions obviously differ. I just give you two examplesThe "C" syntax has actually a flexibility that is very valuable.>
The flexibility is the problem, because you have to specify the loop in
such excruciating detail. It is easy to make a mistake which results in
still legal code. And you now have to analyse each loop to see what kind
of loop it is:
(and there's many variants of these) of not uncommon 'for' usages...
for (c=0; bitstr; c++)
bitstr &= bitstr-1;
for (r=1; r<=0x80; r<<=1)
...
and someone already posted another iteration type on linked listsThese two I get, and I can tell you that they're all WHILE loops. To make make them tidier, I'd have fewer complaints about them if they instead looked like this:
for (node = list; node; node = node->next)
The point here is the observation that there are loops that deviateLet me ask you this: what exactly is the point of the 'while' statement in C? Since it can always be trivially be written as:
from simple counted loops (and that are commonly used) and that they
all comprise the same principal structure; initialization, condition
test, change of loop-variables. The "C" loop syntax reflects that in
its typical low-level syntax form. (I already said that personally I
don't like "C"'s syntax, but I do like its flexibility.)
You can't just say that without explanation. WHY it it nonsense? Take this:[...](This is nonsense.)
>
Suppose you see 'i <= N' as the condition; is that '<=' intentional, or
is it a typo for '<'? It's impossible to tell.
Les messages affichés proviennent d'usenet.