Friday Finking: Contorted loops

Peter J. Holzer hjp-python at hjp.at
Sun Sep 12 16:49:29 EDT 2021


On 2021-09-12 10:28:22 -0700, 2QdxY4RzWzUUiLuE at potatochowder.com wrote:
> On 2021-09-11 at 18:21:17 +0100,
> Alan Gauld via Python-list <python-list at python.org> wrote:
> > On 11/09/2021 15:41, Peter J. Holzer wrote:
> > > How is C's do/while loop more horrible than Pascal's repeat/until? 
[...]
> > so code that has
> > 
> > do{
> > code
> > }
> > while condition;
> > 
> > Looks, for non-trivial cases, like a lot of code followed
> > by an empty while loop.
> > 
> > The do is easy to miss  and the while loop disguised as
> > a repeat termination is confusing.
[...]
> (Side question:  why put the "{" next to the "do," but the "}" and the
> "while" on separate lines?)
> 
> And I would put the while on the same line as the closing brace (which
> is also where I put the "else" in an if statement):
> 
>     do {
>         code;
>     } while(condition);

Me too.

I also checked two C books from "þe olde times" (K&R, 1st editiion,
German translation; and "A Book on C" by Kelley/Pohl) and both nestle the
while on the same line as the closing brace.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20210912/677482ee/attachment.sig>


More information about the Python-list mailing list