A Pair in which the value is a container, is mutable.  And therefore cannot be 
a value type:

$ 6 'my $p = a => my $ = 42; say $p.WHICH; $p.value = 666; say $p.WHICH'
Pair|140196969054016
Pair|140196969054016

Note if the value is *not* a container:

$ 6 'my $p = a => 42; say $p.WHICH; $p.value = 666; say $p.WHICH'
Pair|Str|a|Int|42
Cannot modify an immutable Int
  in block <unit> at -e line 1

I think this is ENOTABUG

> On 15 Aug 2016, at 15:56, Zefram (via RT) <perl6-bugs-follo...@perl.org> 
> wrote:
> 
> # New Ticket Created by  Zefram 
> # Please include the string:  [perl #128948]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=128948 >
> 
> 
> Pair.WHICH has special behaviour if the pair's value is a container:
> 
>> my $a; my $b = :a($a); my $c = :a($a); $a = 3; for $b, $c { say (.WHICH, 
>> .perl) }
> (Pair|47082244733376 :a(3))
> (Pair|47082244733472 :a(3))
> 
> As you can see, both pairs are behaviourally equivalent, in that they
> have the same key and refer to the same value container, thus both seeing
> the change in the value contained in it.  But they get different .WHICH
> values, falsely suggesting that they're distinct.  (=== follows .WHICH
> in falsely indicating that they're distinct.)
> 
> The container case of .WHICH is using the default .WHICH that reflects the
> physical identity of the Pair objects.  To get the intended equivalence,
> Pair.WHICH needs to reflect the key and the identity of the container held
> in the value slot.  I think that just removing the branch of Pair.WHICH
> for the container case would be correct.
> 
> -zefram

Reply via email to