Richard A. O'Keefe
ok at cs.otago.ac.nz
Tue Feb 18 02:36:03 UTC 2003
You have new collection classes? Richard! Why haven't you
posted them on SqueakMap?! :-)
Because I wrote them as an exercise in understanding the ANSI Smalltalk
standard. They are deliberately slightly weird. For example, whenever
ANSI Smalltalk _allows_ a result to be a read-only sequence, I actually
return a read-only sequence. So I have
ListNode (used in Sets)
AssociationListNode (used in Dictionaries)
DateInterval (an interval of Dates, what else?)
ReadOnlyString (an array of UTF-16 codes)
String (adds mutation)
SortedCollection (note: DOESN'T inherit from OrderedCollection)
Things Squeak has that are missing:
SequenceableCollection (basically SequenceReadableCollection)
Heap (I mean to put this in some time)
SkipList and friends
Also, because this was an exercise in understanding the ANSI standard,
whenever the ANSI standard leaves a result unspecified, there isn't any
interesting result. This is quite likely to break existing Squeak code.
And of course, I was trying to understand the ANSI standard, so a lot of
the Squeak methods just aren't there, mainly the standard ones, ones I
needed to implement the standard ones, and ones I couldn't resist.
Bringing this into closer conformity to Squeak would be a LOT of work.
One problem that it's hard to replace _any_ collections without replacing
Right now, for example, with #collect:into:, there are a lot of questions
that need answering. Should WeakSet>>collect: answer a Set or a WeakSet?
Just because we don't want to hold onto the elements we started with, that
doesn't mean we don't want to hold onto the results! I'm inclined to make
it a Set, but could that break anything? Ditto for WeakArray.
If WeakSet>>collect: and WeakArray>>collect: return weak containers,
why do Weak*Dictionary>>collect: return plain OrderedCollections?
Why does WeakSet>>>collect: answer a WeakSet, but WeakRegistry>>collect:
answer a plain Set? It looks to me as if all the Weak* things should
answer plain collections, not weak collections. But would that break
ifNotNil: [aStream nextPutAll: '<this WeakRegistry is locked>; space'].
which should read
ifNotNil: [aStream nextPutAll: '<this WeakRegistry is locked> '].
Building an ANSI-complete set of collection classes was extremely
instructive. One thing it taught me was that I really want Traits.
I am unhappy about the amount of code that had to be copied.
More information about the Squeak-dev