develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24250] "return" required in some anonymous closures

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 21, 2003 07:17
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
20031021141727.GD7867@fdgroup.com
On Tue, Oct 21, 2003 at 02:51:32PM +0100, Robin Barker wrote:
> I found the follow bug today, I think it may be related to this one.
> 
> % perl5.8.1 -lwe 'sub a {} print main->a'
> main
> % perl5.8.0 -lwe 'sub a {} print main->a'
> 
> % perl5.8.1 -lwe 'sub a {return} print main->a'
> 
> % perl5.8.0 -lwe 'sub a {return} print main->a'
> 
> 
> So when the method is empty rather than {return} in perl5.8.1 the object
> is returned.

more accturately, @_ is returned:

$perl5.8.1 -lwe 'sub a {}; print a(3,4,5)'
345



-- 
"Emacs isn't a bad OS once you get used to it.
It just lacks a decent editor."

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