Autrijus Tang wrote:
What should this do, if not infinite loop?
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.
Now let's look at $x = 1. I think it goes down
to the ref and let's it reference the value 1.
This is actually necessary because the ref that $x
"contains" has got other referees---that is the one
stored in $y. Thereafter $y sees the same value 1
through a chain of two references.
"Graphically" this looks as follows:
$y -> ref
\
$x ------> ref -> 1
So I think even $x = \$x should just do the right thing.
And that is not in any way different from $x = $x + 5.
The RHS is evaluated and the resulting value is stored
in $x.
--
TSa (Thomas Sandlaß)