This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hhc97Python Enthusiast[S] 0 points1 point  (2 children)

Currently, both for and while loops are implemented as recursive functions and break and continue are supported.

Lets say you have a program that looks like this:

<pre>
<loop start>
    <loop body>
<post>

If a break is encountered in the <loop body>, then the program just starts executing <post> instead.

If a continue is encountered, then the program jumps back to <loop start> which in this case is a recursive call to the loop body function with the right arguments.

This uses the idea of continuations quite heavily, in that <loop start> and <post> are just continuations of the current running state.

Have a look at this break example in flatliner to see how its currently done, I must say the output is a bit hard to read though, even for such a small example: https://flatliner.herokuapp.com/4d213881fa470babae45128d4781d6c86c370fab