On 9 December 2012 19:34, Marcus Denker <marcus.denker@inria.fr> wrote:
On Dec 9, 2012, at 7:24 PM, Igor Stasenko <siguctua@gmail.com> wrote:
some years ago, its been a long discussion on squeak mailing list about that.. imo association should compare keys. not values.
But it's not very clear why? Why should
(1 -> 2) = (1 -> 4)
be true? They are not the same!
simply for the reason that associations are part of dictionaries. if you need to use associations outside of dicts, why not just using simple arrays? #(1 2) = #( 1 4) or ask yourself, why then we need a distinct class for associations, if its behavior is same as for collection of 2 elements? Lets then just rewrite Dictionary to use array first / array second instead of association key / value.
If you want to compare keys, you can easily write
(1 -> 2) key = (1 -> 4) key
and the people reading the code will directly understand what your intention is.
if we follow this, then all comparison methods in system should be implemented to always compare all fields for equality, without exception. Otherwise you risking to confuse people a lot ! :)
Marcus
-- Best regards, Igor Stasenko.