Thomas Sandlaß skribis 2005-05-04 17:30 (+0200):
> >    my ($x, $y); $x = \$y; $y = \$x; $x[0] = 1;
> Hmm, after the my both $x and $y store an undef.
> Then $x stores a ref to undef. Then $y stores
> a ref to ref of undef. I see no circle.

No, again, please do not make the mistake of thinking VALUES have
identity. VARIABLES (containers) do. A reference points to a container,
never to a value directly. The undef in question is the undef value, not
the undef variable (which exists too).

This is something that doesn't change from Perl 5 to Perl 6.

Try in perl (5) the following code:

    my ($x, $y);
    my ($xx, $yy) = \($x, $y);

They're both undef, but their references are different.

There are names, containers and values.

Declaration and := bind names to containers.

Assignment copies values.

Containers aren't copied.

A reference points to a container.

A name points to a container.

A reference is a value.

The reference isn't to $y's container's value, but to the container.
Regardless of its value. It is also not to the name $y.

> So I think even $x = \$x should just do the right thing.

"The right thing" is the most vague way to describe semantics.

> And that is not in any way different from $x = $x + 5.
> The RHS is evaluated and the resulting value is stored
> in $x.

"$x = $x + 5" overwrites the value of $x's container with the old value
plus five. \$x is the same before and after. The value isn't stored in
$x, but in its container, to which $x is merely a name (implicit
reference).


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to