Sujet : Re: Loops (was Re: do { quit; } else { })
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 20. Apr 2025, 17:07:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vu363o$4t27$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
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 20.04.2025 16:34, Michael S wrote:
On Sun, 20 Apr 2025 14:53:54 +0100
bart <bc@freeuk.com> wrote:
[...]
>
Just such a feature seems to be the primary style of 'for' in
languages such as Ada, Python, Modern Fortran, Odin, Ruby, Julia,
Rust, Matlab, Algol68, Euphoria, Ocaml, Logo, Nim, PL/I, Haxe, Lua,
....
In majority of languages in your list 'for' loops iterates through all
elements of collection. If collection happens to be a range
(terminology shared by python and Rust) then 'for' behaves as a
counting loop. If it isn't then it does not. Even Matlab, despite its
fortranic roots, belongs to that group.
C++ achieve the same objectives [with typical C++ ugliness] by means
of std::foreach.
If I am not mistaken, all exception to that pattern are old languages.
Even Bash has it. All losers?
The Unix standard shell has no counted loops, but it has indexed
arrays, and a 'for' loop that effectively processes just lists.
Kornshell, in its 1988 version the base of POSIX shell, invented
counted loops in its 1993 version but (while adopted by e.g. Bash)
this did not enter the Unix standard. Kornshell also supported
associative arrays. The Unix shells are a big grown conglomerate
of ancient crude syntax. Some shells try to "orthogonalize" their
feature set, but Unix shells are still no appropriate measure for
a sensible language design.
Not all, just many.
Janis