Hi All,
to be able to ease EphemeronDicitonary into the system easily I'd like
to clean up adding associations to Dictionary. It seems to me there's a
partial implementation of choosing an association class appropriate for a
dictionary in the implementors of
associationClass: Dictionary>>#associationClass,
WeakKeyDictionary>>#associationClass,
WeakValueDictionary>>#associationClass,
(& in my image STON class>>#associationClass). This seems workable; an
EphemeronDictionary would simply add associationClass ^ Ephemeron and we're
done, except not quite...
First, HashedCollection does not use associationClass, but it implements
atNewIndex:put: and it strikes me that atNewIndex:put: for Dictionary
really should check for the thing being added at least includingBehavior:
self associationClass. So that means Dictionary should override
atNewIndex:put:.
But what should happen in atNewIndex:put: if the object being added isn't
appropriate? Do we
- raise an error? (that's my preference, but I've got limited use cases in
my head)
- replace the association with one of assocationClass? (seems dangerous to
me but maybe someone needs this or the existing system does this anyway)
- ignore it and hope the user knows what they're doing?
_,,,^..^,,,_
best, Eliot