Two years ago or so, I became very happy to learn that the left side
of binding works just like a routine signature.  So what if binding
*were* just a routine signature.  That is, could we make this:

    sub foo () {
        say "hello";
        my $x := bar();
        say "goodbye $x";
    }

Equivalent to this:

    sub foo () {
        say "hello";
        -> $x {
            say "goodbye $x"; 
        }.(bar());
    }

Then observe:

    sub foo() {
        say "hello";
        my $x := 1|2|3;
        say "goodbye $x";
    }
    
    foo();
    __END__
    hello
    goodbye 1
    goodbye 2
    goodbye 3

If you bind an existing variable (instead of introducing a new one
with my), you get a delimited continuation for the scope of that
variable.  Consequently, if you bind a global, you get a full
continuation.

I know, I know, this is putting continuations into the realm of
!/<upper>{10...}/, but I have an argument for this.  The only people
who will ever see the continuations are the people *implementing*
junctions and junction-like things.  And those people are already
gurus, so they should be comfortable in dealing with continuations.

The only other time that a user might get caught with continuation
"weirdness" is if they're binding to junctions as above (since there
are no other such values in the language... just yet).  And with the
default "no junctions", junctions aren't allowed in variables anyway,
so what do they expect?

Luke

Reply via email to