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

Re: return() in pointy blocks

Thread Previous | Thread Next
From:
Piers Cawley
Date:
June 9, 2005 04:18
Subject:
Re: return() in pointy blocks
Message ID:
m2hdg7kcbx.fsf@obelisk.bofh.org.uk
Luke Palmer <lrpalmer@gmail.com> writes:

> 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.

Having worked through the little and seasoned Schemers, I'm actually at the
point where I can happily think that 'return' is deep scary magic. What I
*want* is a 'proper' continuation, but this would have been close enough for
government work until the real ones came along.


> 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.

Doesn't that call code with the continuation of the caller of
call_with_current_continuation, when it *should* call &code with the
continuation of call_with_current_continuation?

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