On Sat, 4 Sep 2021 12:27:55 -0500, "Michael F. Stemper"
<michael.stem...@gmail.com> declaimed the following:

>
>Kernighan and Ritchie agree(d) with you. Per _The C Programming
>Language__:
>   Experience shows that do-while is much less used that while
>   and for.
>

        And just for confusion, consider languages with "repeat / until"...

        "do / while" repeats so long as the condition evaluates to "true";
"repeat / until" /exits/ when the condition evaluates to "true".

        Then... there is Ada...

        While one is most likely to encounter constructs:

        for ix in start..end loop
                ...
        end loop;

and

        while condition loop
                ...
        end loop;

the core construct is just a bare

        loop
                ...
        end loop;

which, with the "exit when condition" statement allows low-level emulation
of any loop... (same as Python "if condition: break"

        loop    -- "while" loop
                exit when not condition;
                ...
        end loop;

        loop    -- "repeat / until"
                ...
                exit when condition;
        end loop;

        loop    -- split
                ...
                exit when condition;
                ...
        end loop;

{I'm not going to do the "for" loop, but one can easily manage
initialization/increment/test statements}.


        To really get your mind blown, look at loops in REXX...

        do while condition
                ...
        end

        do until condition
                /* note that the termination parameter is listed at top, */
                /* but takes effect at the bottom, so always one pass */
                ...
        end

        do forever
                ...
                if condition then
                        leave
                ...
        end

        do idx = start to end /* optional: by increment */
                ...
        end

        do idx = 1 by increment for repetitions
                ...
        end

AND worse! You can combine them...

        do idx = start for repetitions while condition1 until condition2
                ...
        end

{I need to check if both while and until can be in the same statement}


-- 
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to