[squeak-dev] The Trunk: Collections-ct.972.mcz

Levente Uzonyi leves at caesar.elte.hu
Wed Dec 29 15:28:18 UTC 2021


Hi Christoph,

On Mon, 27 Dec 2021, Thiede, Christoph wrote:

> 
> Hi Levente,
> 
> 
> two goals: First of all, I was assuming that we aim to provide a comprehensive set of features in the Collections package, and having no possibility to customize the key comparison in weak key dictionaries sounded like a
> logical gap to me. There are no senders of WeakKeyDictionary in the Trunk but it IMO still adds value to the package. Second, I am actually having a use case for PluggableWeakKeyDictionary in a third-party package
> (SimulationStudio#34) where I need to compare keys by mirror primitives but still need to hold them weakly.
> 
> 
> I have uploaded this class directly to Trunk because I could not see any harm in it and did not want to create another helper package for Collections. If there was anything wrong with this approach, I apologize and we can
> remove this class immediately again. Still, I would find a PluggableWeakKeyDictionary in the Trunk useful.
> 
> 
> > And I think there might be a better way to do what you want to achieve than copying all those methods.
> 
> 
> What approach were you having in mind concretely? :-)

It is very tempting to make all dictionaries pluggable because it makes 
them a lot more flexible at the cost of a little overhead (both memory 
usage and computation time).

There are probably cases where the "classic" Dictionary and 
IdentityDictionary duo needs to be small (no memory overhead) and fast (no 
run-time overhead), so making those pluggable (in case of Dictionary) or 
non-existant (in case of IdentityDictionary) would not pass with the 
community.

But making other dictionaries (and Sets of course) pluggable should just 
work due to their marginal use (except for special classes like 
MethodDictionary).

So, instead of introducing a mix of the two classes, I suggest you 
should consider simply changing the superclass of WeakKeyDictionary to
PluggableDictionary.
There may be unwanted side-effects that need to be reviewed and fixed, but 
that's not very likely.
Anyway, I suggest you give this a try and see how it works for your 
project. If it looks right, push it to the Trunk (or the Inbox if you're 
not 100% sure it's ready for general consumption).


Levente


More information about the Squeak-dev mailing list