Continuations and threads (was Re: Iterators & generators)

Neel Krishnaswami neelk at brick.cswv.com
Fri Feb 18 19:24:58 EST 2000


Tim Peters <tim_one at email.msn.com> wrote:
> 
> What's *interesting* is what the language could provide if they were
> available to a few insane souls to build on "under the covers".  A
> Scheme True Believer builds all control flow (from function calls
> thru exceptions to pseudo-threading) on top of them.

In fact, that's why I want them; NOT to use directly in code meant to
be read and used on a daily basis, but to be buried discreetly in the
guts of abstractions built on top of them. If they are ever included,
I would expect the standard library to contain warnings like "If you
use the continuation module, expect to confuse yourself."

So I'd want continuations to build backtracking engines in Python
with, which I'd then use to build useful GUI and collection
manipulation libraries, and I'd want 'em to implement exceptions with
restarts, to make exception-handling cleaner and more powerful, and
definitely some slick pattern-matching and FSM schemes are also
possible.

Note that in every case the fact that continuations are used isn't
even exposed to the user of the library, let alone the user of the
application.

Finally, extending bytecodehacks to optimize running code would also
be fun. (This is not as deranged as it sounds! If you store profiling
information, you could theoretically exploit stacklessness and
coroutines to do nifty Self-style dynamic recompilation tricks. In
pure Python, even.)


Neel



More information about the Python-list mailing list