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

Re: `Final' lvsub patch: arrays and hashes

Thread Previous | Thread Next
From:
Simon Cozens
Date:
January 7, 2001 17:53
Subject:
Re: `Final' lvsub patch: arrays and hashes
Message ID:
20010107215901.A9489@pembro26.pmb.ox.ac.uk
On Sun, Jan 07, 2001 at 08:56:32PM +0000, Ton Hospel wrote:
> > 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.

Not so! shift does not make a copy:

 % perl -le '$a= 1; print \$a;foo($a);sub foo { print \do { shift}} '
SCALAR(0x80fa19c)
SCALAR(0x80fa19c)

Remember that we are passing around *values stored in variables*.

-- 
I used to be disgusted, now I find I'm just amused.
		-- Elvis Costello

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