Joshua Gatcomb skribis 2005-05-10 15:52 (-0400):
> sub some_routine {
> my $foo = 42;
> return $foo;
> }
> my $rv := some_routine();
> Should $rv be bound to $foo or to a copy of $foo? I ask because with
> state() and closures, it makes a difference since the value can
> change.
:= is the thing that implements subroutine arguments. Ask yourself the
same question with:
sub another_routine ($rv) {
...
}
another_routine(some_routine());
I'd expect $rv to be an alias to a copy of $foo's value, 42.
UNLESS some_routine is lvalue (which in this case it is not), in which
case, I'd expect $rv to be an alias to $foo itself
> sub some_rourtine {
> state $foo = 42;
> return $foo++;
> }
rvalue some_rourtine: copy 42
lvalue some_rourtine: error, ++ doesn't return an lvalue
(although prefix ++ probably could).
Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html