allSharedPools

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

allSharedPools

Stéphane Ducasse
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
Reply | Threaded
Open this post in threaded view
|

Re: allSharedPools

Mariano Martinez Peck


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

Reply | Threaded
Open this post in threaded view
|

Re: allSharedPools

Stéphane Ducasse
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
>