[squeak-dev] Sets with nil (Was: Ideas about sets and dictionaries)

Levente Uzonyi leves at elte.hu
Thu Nov 12 08:24:41 UTC 2009


Hi,

My plan is to split Set and Dictionary first, then let sets contain nil, 
because dictionaries don't have this issue.

My original idea was to create a class variable in Set called EmptyFlag 
which would take the role of nil as the global marker of empty slots.
I expect it to cause minimal changes in the implementation and have 
similar performance as the current implementation, though it may have 
caveats I didn't think about. Also, WeakSets could be simplified.

But we now have a lot more proposals, let me summarize them all:

- (1)add a new instance variable: containsNil
- (2)use tally to indicate if nil is in the set
  - (a)negative values mean nil is contained by the set
  - (b)floats 
- (3)use a marker object
  - (a)self
  - (b)a unique object in each set
  - (c)a class variable
- (4)use container objects in occupied slots, like associations in 
dictionaries

I prefer 3c, 2a, 3a, 1, 4 in the given order.
What about you?

Cheers,
Levente



More information about the Squeak-dev mailing list