This is a pity that allSharedPools does not return an ordered unique collection.
Class>>allSharedPools "Answer a Set of the pools the receiver shares, including those defined in the superclasses of the receiver." | aSet | ^self superclass == nil ifTrue: [self sharedPools copy] ifFalse: [aSet := self superclass allSharedPools. aSet addAll: self sharedPools. aSet] since sharedPools returns now an orderedCollection I doubt that the uniqueness will the guaranteed. Behavior>>allSharedPools "Answer a Set of the names of the pools (Dictionaries or SharedPool subclasses) that the receiver and the receiver's ancestors share." ^superclass allSharedPools Now on a metaclass we will climb up the inheritance chain for nothing so I would define allSharedPools as follows ClassDescription>>allSharedPools "Answer a Set of the pools the receiver shares, including those defined in the superclasses of the receiver." ^ OrderedCollection new Tell me what you think? Stef |
On Tue, Dec 13, 2011 at 5:01 PM, Stéphane Ducasse <[hidden email]> wrote: This is a pity that allSharedPools does not return an ordered unique collection. I have just tested, and of course, it includes duplicates. Why not a simply: Class>>allSharedPools "Answer a Set of the pools the receiver shares, including those defined in the superclasses of the receiver." | aSet | ^(self superclass == nil ifTrue: [self sharedPools copy] ifFalse: [aSet := self superclass allSharedPools. aSet addAll: self sharedPools. aSet]) asSet ? BTW, why it does a copy ?
I think it answers a list of SharedPool subclasses, not names. Now on a metaclass we will climb up the inheritance chain for nothing so I would define allSharedPools as follows -- Mariano http://marianopeck.wordpress.com |
http://code.google.com/p/pharo/issues/detail?id=5101
check :) About the copy I do not know. > > > On Tue, Dec 13, 2011 at 5:01 PM, Stéphane Ducasse <[hidden email]> wrote: > This is a pity that allSharedPools does not return an ordered unique collection. > > Class>>allSharedPools > "Answer a Set of the pools the receiver shares, including those defined > in the superclasses of the receiver." > | aSet | > ^self superclass == nil > ifTrue: [self sharedPools copy] > ifFalse: [aSet := self superclass allSharedPools. > aSet addAll: self sharedPools. > aSet] > > since sharedPools returns now an orderedCollection I doubt that the uniqueness will the guaranteed. > > > > I have just tested, and of course, it includes duplicates. Why not a simply: > > Class>>allSharedPools > "Answer a Set of the pools the receiver shares, including those defined > in the superclasses of the receiver." > | aSet | > ^(self superclass == nil > ifTrue: [self sharedPools copy] > ifFalse: [aSet := self superclass allSharedPools. > aSet addAll: self sharedPools. > aSet]) asSet > > ? > > BTW, why it does a copy ? > > > Behavior>>allSharedPools > "Answer a Set of the names of the pools (Dictionaries or SharedPool subclasses) that the receiver and the receiver's ancestors share." > > ^superclass allSharedPools > > > I think it answers a list of SharedPool subclasses, not names. > > > Now on a metaclass we will climb up the inheritance chain for nothing so I would define allSharedPools as follows > > ClassDescription>>allSharedPools > "Answer a Set of the pools the receiver shares, including those defined > in the superclasses of the receiver." > > ^ OrderedCollection new > > Tell me what you think? > > Stef > > > > -- > Mariano > http://marianopeck.wordpress.com > |
Free forum by Nabble | Edit this page |