develooper Front page | perl.perl6.language | Postings from June 2005

Re: return() in pointy blocks

Thread Previous | Thread Next
Luke Palmer
June 8, 2005 15:51
Re: return() in pointy blocks
Message ID:
On 6/8/05, Piers Cawley <> wrote:
> > In other words, it outputs:
> >
> >    Foo
> >    Foo
> >    # dies

Yep.  My mistake.

> If that works, then I think it means we can write:
>     sub call-with-current-continuation(Code $code) {
>         my $cc = -> $retval { return $retval }
>         $code($cc);
>     }
> Which I personally think is rather cute. Even if I can't quite bring myself to
> believe it's that simple...

Yeah, that's pretty.  But that will bite people who don't understand
continuations; it will bite people who don't understand "return"; it
will even bite people who understand continuations, because they can
be made in such an awkward form so easily.

Currently call/cc is done like this:

    sub call_with_current_continuation(&code) {

But that might be broken in pugs at the moment.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About