develooper Front page | perl.perl5.porters | Postings from January 2011

Re: [perl #72724] lvalue subs

Thread Previous
From:
Dave Mitchell
Date:
January 3, 2011 04:10
Subject:
Re: [perl #72724] lvalue subs
Message ID:
20110103121017.GQ10901@iabyn.com
On Sun, Dec 12, 2010 at 01:44:40PM -0800, Father Chrysostomos wrote:
> I would like to propose some changes to the way lvalue subs work.
> 
> Right now the docs say that you can’t use return. This just makes them
> so much less useful than they could be.
> 
> Currently, return($bar) in an lvalue sub returns a new scalar as it
> would if there had been no :lvalue. I think return($bar) should have the
> same effect as falling off the end of the subroutine with $bar as the
> last statement.
> 
> This is also an error currently if an lvalue sub contains ‘return 7’ or
> has ‘7’ as the last statement (Can't modify constant item in lvalue
> subroutine return). This also makes them far less useful than they could
> be, as there is no way to indicate that a sub *might* return an lvalue.
> Sometimes it is useful to return a read-only value if the input consists
> of read-only values (just as substr does), which is fine in rvalue
> context. (And the fact that return ${\7} works but return 7 does not is
> a good indication that it is a bug.)
> 
> I am toying with the idea of fixing lvalue subs (and upgrading them from
> experimental status), but I need to know how to proceed.

Your proposal sounds good.

> I attached this message to ticket #72724, as it seemed an appropriate
> place to record the mile-long thread that will shortly ensue.

Hope you weren't holding your breath :-)

-- 
Never do today what you can put off till tomorrow.

Thread Previous


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