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

Re: `Final' lvsub patch: arrays and hashes

Thread Previous | Thread Next
From:
Graham Barr
Date:
January 7, 2001 13:16
Subject:
Re: `Final' lvsub patch: arrays and hashes
Message ID:
20010107211513.C12732@pobox.com
On Sun, Jan 07, 2001 at 08:56:32PM +0000, Ton Hospel wrote:
> In article <20010107175242.A1935@pembro26.pmb.ox.ac.uk>,
> 	Simon Cozens <simon@cozens.net> writes:
> > On Sun, Jan 07, 2001 at 12:30:06PM -0500, Ronald J Kimball wrote:
> >> >     sub foo :lvalue {shift}  foo($a) = 7 
> >> 
> >> "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".
> > 
> > Fair enough. Try this:
> >     I am returning a value from a subroutine.
> >     The value I am returning is the value of the first parameter.
> >     The value of first parameter of the subroutine is modifiable.
> >     The value that I am returning is modifiable.
> > 
> > Where's the fallacy?
> 
> You are returning a COPY of the value of the first parameter.
> shift does not give an lvalue

That is not completely true.

  sub abc { return \shift }

  $a = 1;
  $b = abc($a);
  warn $$b;
  ${$b}++;
  warn $a;

Graham.


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