Sujet : Re: Loops (was Re: do { quit; } else { })
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 19. Apr 2025, 08:09:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtvi6d$tm6c$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 18.04.2025 19:27, bart wrote:
[...]
C is quite different; it is merely 3 arbitrary expressions, the middle
one of which is used as a loop terminating condition (tested notionally
at the start of the loop).
They're not "arbitrary".
They are chosen by the software designer to fulfill the demands.
You've already and often demonstrated that you have problems to
grok non-trivial loops. But I'll anyway support you with another
example (here from C++, but the principle is the same)
for (unsigned int i = 0; aa.notEmpty(); i++)
for (Arabic a = a2r_tab[i].arabic;
aa.contains(a);
aa.remove(a))
r += a2r_tab[i].roman;
for (unsigned int i = 0; rr.notEmpty(); i++)
for (Roman r = r2a_tab[i].roman;
rr.contains(r);
rr.remove (r))
a += r2a_tab[i].arabic;
All elements in the nested loops are algorithmically connected,
they are not "arbitrary". - I don't expect that (without context
or comments) anyone understands that; the point is that you just
cannot formulate the algorithm with primitive loops. And another
point is that these algorithms are using these _equivalent_ loop
hierarchies despite working on completely different data types,
so the (for you probably perceived as unrelated) interconnection
of the loop elements in the loop hierarchy is meaningful.
So I think above you meant to say that the loop expressions are
not "tightly coupled". - Yes, they are not, and thus can be used
in more advanced algorithmic contexts.
Janis
[...]