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

Re: `Final' lvsub patch: arrays and hashes

Thread Previous | Thread Next
January 7, 2001 20:57
Re: `Final' lvsub patch: arrays and hashes
Message ID:
In article <>,
	Simon Cozens <> writes:
> 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*.

Right (didn't know that until you and graham pointed that out). The
essence seem to be we have *two* "lvalue" concepts:
1) Something we can assign to
2) Something we can get hold of (through a container) and so manipulate

It has to be decided which one of these two meanings we should use
Or maybe we should just make them the same concept, i.e., make things
like this work:

sub fun {

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About