Ingo Blechschmidt writes: > that's really convenient, but what will the following code do? > my $x = (a => 42); # $x is a Pair. > $x = 13; # Is $x now the Pair (a => 13) or > # the Int 13?
It's the Int 13. Your example looks a lot like this one: my $x = [ 1, 2, 3 ]; $x = 13; And you could say that is an error because: [ 1, 2, 3 ] = 13; Is an error, but you'd be wrong. You see, in your example, the pair is not "functioning as an lvalue". The variable is the thing that is the lvalue, not the pair. I belive you could get the pair as an lvalue if you did: my (Pair $x) := (a => 42); $x = 13; Because the variable x is now *fundamentally* a pair; it has no container, so to speak. But it would die, because you're trying to change a constant value. Luke