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

Re: return() in pointy blocks

Thread Previous | Thread Next
From:
Piers Cawley
Date:
June 7, 2005 09:52
Subject:
Re: return() in pointy blocks
Message ID:
m2zmu2kt2z.fsf@obelisk.bofh.org.uk
Ingo Blechschmidt <iblech@web.de> writes:

> Hi, 
>  
>   sub foo (Code $code) { 
>     my $return_to_caller = -> $ret { return $ret }; 
>  
>     $code($return_to_caller); 
>     return 23; 
>   } 
>  
>   sub bar (Code $return) { $return(42) } 
>  
>   say foo &bar; # 42 or 23? 
>  
> I think it should output 42, as the return() in the pointy 
> block $return_to_caller affects &foo, not the pointy block. 
> To leave a pointy block, one would have to use leave(), right? 

That's how it's defined in the relevant Apocalypse. And that's how I hope it'll
stay.


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