non-string keys (in a BagHash, for example)

2014-12-01 Thread Theo van den Heuvel
Hi all, I was hoping to store objects of class Foo in a BagHash in the expectation that objects that are the same share their keys. But if I do something like my $b = BagHash.new(); for 1..3 { $b{['foo']}++; } say $b.perl; #(perl6 version 2014.09 built on MoarVM version 2014.09, Windows

Re: non-string keys (in a BagHash, for example)

2014-12-01 Thread Carl Mäsak
Theo van den Heuvel (): Perl6 considers all entries as new, and the hash has 3 separate entries. Do I actually have to project my objects to strings to accomplish this? You're putting arrays into a hash. When you put something into a hash, it matters whether the object in question has

Re: non-string keys (in a BagHash, for example)

2014-12-01 Thread Carl Mäsak
Yes, the WHICH method controls how the hashing happens. But the more fundamental principle is that the method always return the same value for the same objects. This tends to be implemented by returning either (a representation of) the reference, or the value itself (which must then not be