[Python-Dev] Stackless Python - Pros and Cons (original) (raw)

Tim Peters tim_one@email.msn.com
Sun, 6 Aug 2000 21:16:44 -0400


[Tim]

IMO, the real reason we don't have generators already is that they keep getting hijacked by continuations (indeed, Steven gave up on his patches as soon as he realized he couldn't extend his approach to continuations).

[esr]

This report of repeated "hijacking" doesn't surprise me a bit. In fact, if I'd thought about it I'd have expected it. We know from experience with other languages (notably Scheme) that call-with- current-continuation is the simplest orthogonal primitive that this whole cluster of concepts can be based on. Implementors with good design taste are going to keep finding their way back to it, and they're going to feel incompleteness and pressure if they can't get there.

On the one hand, I don't think I know of a language not based on Scheme that has call/cc (or a moral equivalent). REBOL did at first, but after Joe Marshal left, Carl Sassenrath ripped it out in favor of a more conventional implementation. Even the massive Common Lisp declined to adopt call/cc, the reasons for which Kent Pitman has posted eloquently and often on comp.lang.lisp (basically summarized by that continuations are, in Kent's view, "a semantic mess" in the way Scheme exposed them -- btw, people should look his stuff up, as he has good ideas for cleaning that mess w/o sacrificing the power (and so the Lisp world splinters yet again?)). So call/cc remains "a Scheme thing" to me after all these years, and even there by far the most common warning in the release notes for a new implementation is that call/cc doesn't work correctly yet or at all (but, in the meantime, here are 3 obscure variations that will work in hard-to-explain special cases ...). So, ya, we do have experience with this stuff, and it sure ain't all good.

On the other hand, what implementors other than Schemeheads do keep rediscovering is that generators are darned useful and can be implemented easily without exotic views of the world. CLU, Icon and Sather all fit in that box, and their designers wouldn't touch continuations with a 10-foot thick condom .

This is why I'm holding out for continuation objects and call-with-continuation to be an explicit Python builtin. We're going to get there anyway; best to do it cleanly right away.

This can get sorted out in the PEP. As I'm sure someone else has screamed by now (because it's all been screamed before), Stackless and the continuation module are distinct beasts (although the latter relies on the former). It would be a shame if the fact that it makes continuations possible were to be held against Stackless. It makes all sorts of things possible, some of which Guido would even like if people stopped throwing continuations in his face long enough for him to see beyond them <0.5 wink -- but he doesn't like continuations, and probably never will>.