On 2021-09-10 12:26:24 +0100, Alan Gauld via Python-list wrote: > On 10/09/2021 00:47, Terry Reedy wrote: > > even one loop is guaranteed.) "do-while" or "repeat-until is even rarer > > since fractional-loop include this as a special case. > > Is there any empirical evidence to support this? > Or is it just a case of using the tools that are available? > In my experience of using Pascal (and much later with Delphi) > that I used repeat loops at least as often as while loops, > possibly more. > > But using Python and to a lesser extent C (which has a > rather horrible do/while) construct
How is C's do/while loop more horrible than Pascal's repeat/until? They
seem almost exactly the same to me (the differences I see are the
inverted condition (debatable which is better) and the added block
delimiters (which I actually like)).
> So is it the case that the "need" for repeat loops is
> rare, simply a result of there being no native repeat
> loop available?
A tiny non-representative data point:
In an old collection of small C programs of mine I find:
35 regular for loops
28 while loops
2 infinite for loops
1 "infinite" for loop (i.e. it exits somewhere in the middle)
0 do/while loops.
So even though do/while loops are available in C (and I don't find them
horrible) I apparently found very little use for them (I'm sure if I
look through more of my C programs I'll find a few examples, but this
small samples shows they are rare.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
