On Wed, Apr 05, 2017 at 01:33:58AM +0200, Elizabeth Mattijsen wrote: > > On 4 Apr 2017, at 11:31, Trey Ethan Harris <treyhar...@gmail.com> wrote: > > > > I'm thinking of a Hash-like collection where I can add objects using a > > index-less append operation, but then have random access to the elements > > based on a key provided by the object. (For instance, imagine a > > ProcessTable, where I create the collection telling it to index by the .pid > > method, add each process to %table in serial without mentioning pid, and > > then look up the one referring to the interpreter with %table{$*PID}.) > > This is basically the approach that object hashes take internally. So, feels > to me you just need object hashes? > > https://docs.perl6.org/type/Hash#index-entry-object_hash > > Objects are internally keyed to the result of the .WHICH method on that > object. If you create a class, one will be provided for you automatically. > But there’s nothing preventing you from making your own .WHICH method, as > long as the result is consistent for a given object and the same for all > objects you think should be considered identical, you should be fine.
I didn't know this but in OO land one would use a functorfactory to produce hash functions or transformation functions on objects (some sort of apply gain.) holly