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

Re: return() in pointy blocks

Thread Previous | Thread Next
From:
Luke Palmer
Date:
June 8, 2005 15:51
Subject:
Re: return() in pointy blocks
Message ID:
7ca3f01605060815516181e6dc@mail.gmail.com
On 6/8/05, Piers Cawley <pdcawley@bofh.org.uk> 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) {
        &code(&?CALLER_CONTINUATION);
    }

But that might be broken in pugs at the moment.

Luke

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About