2009/7/3 Andres Valloud <avalloud@smalltalk.comcastbiz.net>:
Why does #like: have to be disabled? Â Why can't you provide an implementation for it?
Every add: has an additional nil check. Â I'd bet that in 99.9999% of the cases, the nil check is effectively overhead. Â In efficient implementations of hashed collections, you can tell when you add a few message sends because it costs about 10% (as I measured for findElementOrNil: in VW's IdentitySet).
you forgot that #add: in Set has an additional nil check already :)
Besides the additional complexity, is do: actually correct? Â How can a set includeNil but have a tally of 0? Â I am suspicious that add: should increase the tally when you add nil (more complexity).
again, 'tally' is an internal state. Not something you can see or meaningfully use outside.
Every removal has an additional nil check. Â I also note that the tally is not updated either...
well, you can test it, if you think it wrongly implemented.
So. Â I wanted to point out that these 8 refined methods give you:
* Inflexible implementation. Â If Set changes, then you have to change GenericSet too.
can't accept such argument. Should i implement it from scratch by subclassing from Object?
* Additional code complexity that people have to deal with.
where? and what you mean by 'deal with'? Did i extended a Set protocol, or something like that?
* But you can add nil to a Set.
Let's say you write code with GenericSet and use the fact that you can add nils. Â In the vast majority of Smalltalks (all?), you can't add nil to a set. Â So, if you want to port code, you have to port GenericSet (and apply the necessary refinements N times). Â You can't use the everyday Set that IIRC is specified in the ANSI standard.
I can say similar about situations where you need to use sets where it meaningfully can contain nils. Each time, in every such place, you have to write a workarounds to count nil separately. Now compare this with a class, which provides you this in a simple and usual manner.
Again, is it worth the effort?
Finally, of course you compare GenericSet to e.g.: HPS, and there's no complexity at all. Â Nevertheless, I've come to think that "I can do it" generally doesn't mean "I should do it".
Sure thing. But you will recall my words each time when you will need to deal with nil, as with useful and valuable object, which you can treat in same way as others.
Andres.
-- Best regards, Igor Stasenko AKA sig.