So, I must ask, what does this do:

    sub foo() {
        return my $self = {
            print "Block";
            return $self;
        }
    }
    
    my $block = foo;
    print "Main";
    $block();
    print "End";

That is, the block returns from a function that's not currently
executing.

Will the output be: a)

    Can't 'return' from closure Block

b)

    Main
    Block
    Can't 'return' from closure Block

(just like (a) but runtime)
c)

    Main
    Block

(the block's return returns from the main program, or whatever function
is currently executing)

d)

    Main
    Block
    Main
    Block
    Main
    Block
    ...

(the block closes over the function's return continuation)

(a) and (b) both sound pretty good.  (c) is a very bad idea, as it's
very subtle, breaks return type safety, introduces unexpected control
flow, etc.  We'll leave those responsibilites to C<leave> :-)

Maybe (d) is the way we slip in continuations without anyone noticing.
It's the only one of these possibilites that works intuitively with, eg.
"grep".  It still seems like it might too easily introduce subtle bugs. 

Is there another meaningful possibility that I didn't cover?  I've heard
Smalltalk has something equivalent to the sub/block distinction; what
does it do?

Luke

Reply via email to