[Python-Dev] A "real" continuation example

Tim Peters tim_one at email.msn.com
Thu May 20 09:21:45 CEST 1999


[Sam, takes up the Continuation Python Challenge]

Thanks, Sam!  I think this is very helpful.

> ...
> It's the only way to do it - every example I've seen of using call/cc
> looks just like it.

Same here -- alas <0.5 wink>.

> I reworked your Scheme a bit.  IMHO letrec is for compilers, not for
> people.  The following should be equivalent:

I confess I stopped paying attention to Scheme after R4RS, and largely
because the std decreed that *so* many forms were optional.  Your rework is
certainly nicer, but internal defines and named let are two that R4RS
refused to require, so I always avoided them.  BTW, I *am* a compiler, so
that never bothered me <wink>.

>> So what would this look like in Continuation Python?

> Here's my first hack at it.  Most likely wrong.  It is REALLY HARD to
> do this without having the feature to play with.

Fully understood.  It's also really hard to implement the feature without
knowing how someone who wants it would like it to behave.  But I don't think
anyone is getting graded on this, so let's have fun <wink>.

Ack!  I have to sleep.  Will study the code in detail later, but first
impression was it looked good!  Especially nice that it appears possible to
package up most of the funky call_cc magic in a base class, so that
non-wizards could reuse it by following a simple protocol.

great-fun-to-come-up-with-one-of-these-but-i'd-hate-to-have-to-redo-
    from-scratch-every-time-ly y'rs  - tim






More information about the Python-Dev mailing list