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

Re: return() in pointy blocks

Thread Previous | Thread Next
From:
Piers Cawley
Date:
June 8, 2005 14:31
Subject:
Re: return() in pointy blocks
Message ID:
m2oeagk01s.fsf@obelisk.bofh.org.uk
"TSa (Thomas SandlaƟ)" <Thomas.Sandlass@orthogon.com> writes:

> Piers Cawley wrote:
>> [..] then I think it means we can write:
>>     sub call-with-current-continuation(Code $code) {
>>         my $cc = -> $retval { return $retval }
>
> For the records: the return here is the essential ingredient, right?
> Without it the block would be evaluated or optimized away to an undef
> or some such.

Yes. Without the return you just get block that returns the value its last
expresion to the place from which it (the pointy sub) was called, rather than
to the place that the subroutine that created it was called from.

>
>>         $code($cc);
>>     }
>> Which I personally think is rather cute.
>
> Me too!
>
>
>> Even if I can't quite bring myself to
>> believe it's that simple... 
>
> I have convinced myself.
> How can I be of assistance on your side?

How's your Haskell?

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