allSeclectors vs. allSelectorsUnderstood

Scott Wallace scott.wallace at squeakland.org
Fri Nov 15 12:06:43 UTC 2002


Andrew,

It looks like #allSelectorsUnderstood was put in not as a proactive 
alternative to #allSelectors but because in the moment I was 
oblivious to the existence of #allSelectors (notice that the two 
methods are in different method categories,) and just threw together 
an expedient method that produced what I needed.

So you're right that it would be good to expunge 
#allSelectorsUnderstood, and replace its senders with calls to 
"allSelectors asArray".   (Or at least, as you suggest, give the 
method a more apt name and clean it up.)

A good candidate for the coming round of cleanups under the new regime!

Cheers,

   -- Scott


At 11:45 PM -0800 11/14/02, Andrew P. Black wrote:
>Does anyone know why Behavior has methods allSelectors and 
>allSelectorsUnderstood?  As far as I can tell, they always answer 
>essentially the same thing, except that the first returns an 
>IdentitySet, and the second an Array.
>
>Behavior >> allSelectors
>	| temp |
>	superclass
>		ifNil: [^ self selectors].
>	temp _ superclass allSelectors.
>	temp addAll: self selectors.
>	^ temp
>
>Behavior >> allSelectorsUnderstood  (sw 12/01/2000)
>	"Answer a list of all selectors understood by instances of 
>the receiver"
>
>	| aList |
>	aList _ OrderedCollection new.
>	self withAllSuperclasses do:
>		[:aClass | aList addAll: aClass selectors].
>	^ aList asSet asArray
>
>"SketchMorph allSelectorsUnderstood size"
>
>
>The coding the second version seems easier to read,  but it makes no 
>sense to build up an OrderedCollection just to turn it into a set. 
>I propose rewriting as follows:
>
>Behavior >> allSelectors
>	"Answer a set of all selectors defined by this class and its 
>superclasses"
>
>	| aSet |
>	aSet _ Set new.
>	self withAllSuperclasses do:
>		[:aClass | aSet addAll: aClass selectors].
>	^ aSet
>
>
>The only place that allSelectorsUnderstood appears to be used is in 
>Lexicon (whatever that is).  If a client really wants an Array 
>(rather than a Set) then "aClass allSelectors asArray" would seem to 
>be a fine idiom; there does not seem to be much justification for 
>allSelectorsUnderstood to exist as a separate method, and in any 
>case the "understood" suffix is wrong (these are the selectors 
>_defined_ by the class in question and its superclasses, not 
>understood by it) and does not capture the distinction (Array rather 
>than Set).
>
>I'm being a bit tentative about this because I think that "sw" is 
>Scott Wallace, and if so there is probably something much deeper 
>going on here than I suspect
>
>	Andrew




More information about the Squeak-dev mailing list