[Stackless] Re: [Python-Dev] Stackless pages

Greg Wilson gvwilson at nevex.com
Mon Nov 6 14:39:37 CET 2000

> Jeremy wrote:
> I tend to agree with you, Guido.  I think we would do well to purposefully
> omit continuations from the Python language.  There seems to be little need
> for a facility to implement arbitrary control structures in Python.  If
> Python support coroutines and microthreads, I am not sure what else would be
> needed.

I just finished reading Thomas and Hunt's "Programming Ruby" (the first book in
English on the language).  It's pretty clear that their favorite language
feature in Ruby is the block, which is any group of statements inside either
braces or do...end.  Blocks are invoked using the 'yield' construct, and can
take any number of arguments (enclosed in bars):

    def fibUpTo(max)
      i1, i2 = 1, 1
      while i1 <= max
        yield i1                      # 'call' the block
        i1, i2 = i2, i1 + i2

    fibUpTo(1000) { |f| print f, " " }

Most built-in types have iterators that understand blocks:

    [1, 3, 5].each { |i| puts i }     # prints 1, 3, and 5 on separate lines

Programmers can use blocks and 'yield' to create new control structures, subject
to the limitation that a statement can only be given one block (which means that
a multi-way interleaving loop can't be built out of blocks).  It would be
interesting to see how many of their examples can be done (easily) with


Stackless mailing list
Stackless at starship.python.net

More information about the Stackless mailing list