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

Re: `Final' lvsub patch: arrays and hashes

Thread Previous | Thread Next
From:
Ronald J Kimball
Date:
January 7, 2001 09:30
Subject:
Re: `Final' lvsub patch: arrays and hashes
Message ID:
20010107123006.A34104@linguist.thayer.dartmouth.edu
On Sun, Jan 07, 2001 at 01:14:39PM +0000, Simon Cozens wrote:
> On Fri, Jan 05, 2001 at 10:10:54AM -0800, Stephen McCamant wrote:
> > If you like being able to assign to shift, I'd like to hear an argument why.
> 
> I'm not assigning to shift, I'm assigning to the return value of the
> subroutine. The documentation says it is possible to return a modifiable value
> from a subroutine: sub foo : lvalue { shift } returns $_[0].
> I consider these to be equivalent:
> 
>     sub foo { $_[0] = 7; }   foo($a)
>     sub foo :lvalue {shift}  foo($a) = 7 
>  

These are not equivalent:

    sub foo { $_[0] = 7; }  foo($a)
    sub foo { shift = 7; }  foo($a)

So I don't know why you would expect your examples to be equivalent.

"it is possible to return a modifiable value from a subroutine" does not at
all mean the same thing as "all values returned from a subroutine are
modifiable".



Ronald

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