Sujet : Re: Loops (was Re: do { quit; } else { })
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 18. Apr 2025, 15:40:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtto81$37l6h$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
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 16.04.2025 13:01, bart wrote:
On 16/04/2025 06:19, Janis Papanagnou wrote:
On 15.04.2025 12:30, bart wrote:
(One of your fundamental problems with "C" seems to be to understand
the 'for' keyword meaning only counted loops with one variable and a
simple +1 increment. - I can't help you here.)
And your problem seems to the opposite: being unable to understand that
for-loop (perhaps spelled 'do') can be a specialised feature to iterate
one or more variables over a predetermined range or set of values.
Why do you think so? - I've given enough examples where you could
have easily seen that I'm able to take advantage for my programming
of any loop concept that languages provide, and I've done so, from
Pascal's simple forms, over Simula and Algol 68 loops, to "C"/C++
loops and loop algorithms, or Unix Shell's or Awk's loop constructs.
But if I'd want to use some flexibility of one language and don't
have it available in another language I'll have to work around it.
And, vice versa, if I have that flexibility, why not use it.
Unlike C's for, which is just a gimmick where you bundle three
potentially unrelated expressions and hope for the best.
It's nothing to do with hope. (Your religious approach here is not
very useful if you want to work as [or become] a serious programmer.)
If you are intellectually incapable of managing "C" loops I cannot
help you. - But I have sympathy for you, and can feel your pain if
you're programming in "C" given what you are repeatedly complaining
about.
Everyone here is defending the latter to the death. Why? Apparently the
ONLY argument is 'flexibility'.
Why do you think so? - Flexibility is what "C"'s loop provides; it's
one of the strengths of this loop. - Your agenda and opinion on that
seems to be different, you certainly cannot see or acknowledge that
flexibility and instead try to invalidate that fact repeatedly by
red herrings.
I see that you're priorities are, as you've shown, for example, how
many characters you have to type, or whether you have do..od syntaxes
available as part of the language.
I cannot believe that you never used any of the possibilities that
"C" loops provide us. But okay, it's anyway meaningless what you do.
Having to writing a simple iteration in such a convoluted and unchecked
manner is much better because - you can use the same syntax to iterate
over a list!
I understand that you want a primitive loop being available. - And
if that's such a pain that "C" doesn't have it I'd suggest you to
switch to another language; for your private stuff you can do what
you like, there's no prerequisites or boundary conditions imposed
upon you.
I've written code where the logic required comparisons of i < N-1
and also i <= N . So what? - Should I not do that because you are
getting confused when inspecting my code?
This is worrying. So you have a bunch of code with multiple like this:
for (i=0; i<N; ++)
for (i=0; i<N; ++)
for (i=0; i<=N; ++)
for (i=0; i<N; ++)
No. I have written code as I wrote it - still quoted above - not as
you made it up. I haven't said anything else about it. - Only that I
have no issues to apply every form as algorithmic demands require it.
And you notice one has <= while the others have <. But according to you,
this is nothing remarkable and raises no flags. Obviously the author
intended to iterate one more time there!
Yes, different contexts require different implementations.
(It appears strange to me that your programs look all the same. And,
honestly, I cannot believe that; I think you're as usual just making
that up.)
With language-supported iteration, the comparison operator is not
exposed, so the programmer cannot accidentally type the wrong one.
Obviously.
(I see I have ++ and not ++i; never mind. It is telling that it took me
a minute to notice!)
Get some glasses?
Janis