[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] environment/shared pool search order?
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] environment/shared pool search order? |
Date: |
Tue, 10 Apr 2007 08:06:11 +0200 |
User-agent: |
Thunderbird 1.5.0.10 (Macintosh/20070221) |
Stephen Compall wrote:
STSymbolTable uses an IdentitySet to store pool dictionaries and
environments. This is fine ordinarily, but loses the search order
imposed by find_class_variable in sym.c. Perhaps what is needed is the
semantics of an "ordered identity set"?
That's right. The simplest way to implement such a thing is
to subclass IdentitySet, adding something like
initialize: size
super initialize: size.
orderedCollection := OrderedCollection new: size.
remove: anObject ifAbsent: aBlock
self shouldNotImplement
primAt: anIndex put: anObject
orderedCollection addLast: anObject
do: aBlock
orderedCollection do: aBlock
The best way to do so would be the other way round:
subclass OrderedCollection, wrapping all the "add" methods
with a test for inclusion (using the hashed collection),
and redefining #includes: so that it uses the hashed
collection. This would have the advantage that you
could use the same class for both OrderedSet and
OrderedIdentitySet.
Either choice is fine with me.
Paolo