Python-based monads essay part 2

Marko Rauhamaa marko at pacujo.net
Thu Oct 20 07:15:29 EDT 2016


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> Marko Rauhamaa wrote:
>
>>     def main():
>>         try:
>>             guard_it()
>>         except ValueError:
>>             # I'm having none of it!
>>             resume "CarryOn!"
>>
>> The problem is, how can the file f unclose itself when work resumes?
>
> The same thing could happen in Scheme, though. Re-entering a context
> via a continuation doesn't magically reset everything to the way it
> was at some earlier time. A data structure that has been mutated will
> still be mutated, and a file that has been closed will still be
> closed.

Obviously. However, Scheme continuations are (or can be) used to
implement all other single-threaded paradigms (coroutines, generators,
exceptions etc), so the execution context quite normally jumps around
"erratically". There is no automatic method to decide when final is
final.


Marko



More information about the Python-list mailing list