Re: RFC 132 (v1) subroutines should be able to return an lvalue

[email protected] (Jarkko Hietaniemi) Fri, 18 Aug 2000 10:27:27 -0500
Newsgroups perl.perl6.language.subs
Message-ID <[email protected]>
On Fri, Aug 18, 2000 at 10:30:32AM -0500, Jonathan Scott Duff wrote:
> On Fri, Aug 18, 2000 at 10:09:22AM -0500, Jarkko Hietaniemi wrote:
> > > The clue is "If a sub wants to return an lvalue, it must B<be> an
> > > lvalue". Therefore I propose a new keyword C<lreturn> that behaves
> > > just like C<return>, but returns the lvalue instead of the rvalue. After
> > > returning, everything is exactly as if the argument to lreturn were
> > > specified instead of the subroutine call. The <:lvalue> property is no
> > > longer needed and should be removed sine it only causes confusion. A
> > > subroutine B<is> not an lvalue thing, it B<returns> an lvalue if it
> > > wants to.
> > 
> > Amen.
> > 
> > (Tagging a sub to _always_ be an lvalue runs very counter to the flexible
> >  context concept of Perl, witness the want()).
> 
> But why introduce a new keyword "lreturn"?  What about something like
> this?
> 
> 	sub foo {
> 	    my $lvalue : lvalue;
> 	    ...
> 	    return $lvalue if want('LVALUE');
> 	}

Error proneness?  (Is that a word?)

 	sub foo {
 	    my $lvalue;
 	    ...
 	    return $lvalue if want('LVALUE');
 	}
-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen