SystemNavigation >> #allMethodsSelect:localTo:

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

SystemNavigation >> #allMethodsSelect:localTo:

Frank Shearar-3
allMethodsSelect: aBlock localTo: aClass
    "Answer a SortedCollection of each methodr in, above, or below the given
    class that, when used as the argument to aBlock, gives a true result."

    | aSet |
    aSet := Set new.
    Cursor wait showWhile:
        [aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]].
        aClass theNonMetaClass class withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]]].
    ^aSet

Um. That is just an accidental duplication of the aClass
theNonMetaClass class withAllSuperAndSubclassesDoGently: block, right?

frank

Reply | Threaded
Open this post in threaded view
|

Re: SystemNavigation >> #allMethodsSelect:localTo:

Eliot Miranda-2


On Tue, May 21, 2013 at 2:40 PM, Frank Shearar <[hidden email]> wrote:
allMethodsSelect: aBlock localTo: aClass
    "Answer a SortedCollection of each methodr in, above, or below the given
    class that, when used as the argument to aBlock, gives a true result."

    | aSet |
    aSet := Set new.
    Cursor wait showWhile:
        [aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]].
        aClass theNonMetaClass class withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]]].
    ^aSet

Um. That is just an accidental duplication of the aClass
theNonMetaClass class withAllSuperAndSubclassesDoGently: block, right?

No, it's not :)  It's preserving existing behavior, which is to search class and instance side.  Note that

 aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
    [:class|
    {class. class class} do: aBlock

is not equivalent to 

    aClass theNonMetaClass withAllSuperAndSubclassesDoGently: aBlock
    aClass theNonMetaClass class withAllSuperAndSubclassesDoGently: aBlock

because the latter searches Behavior, ClassDescription, Class etc, while the former doesn't.


frank




--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: SystemNavigation >> #allMethodsSelect:localTo:

Eliot Miranda-2


On Tue, May 21, 2013 at 2:53 PM, Eliot Miranda <[hidden email]> wrote:


On Tue, May 21, 2013 at 2:40 PM, Frank Shearar <[hidden email]> wrote:
allMethodsSelect: aBlock localTo: aClass
    "Answer a SortedCollection of each methodr in, above, or below the given
    class that, when used as the argument to aBlock, gives a true result."

    | aSet |
    aSet := Set new.
    Cursor wait showWhile:
        [aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]].
        aClass theNonMetaClass class withAllSuperAndSubclassesDoGently:
            [:class |
                class selectorsAndMethodsDo:
                    [:aSelector :aMethod|
                        (aBlock value: aMethod) ifTrue:
                            [aSet add: (MethodReference new
setStandardClass: class methodSymbol: aSelector)]]]].
    ^aSet

Um. That is just an accidental duplication of the aClass
theNonMetaClass class withAllSuperAndSubclassesDoGently: block, right?

No, it's not :)  It's preserving existing behavior, which is to search class and instance side.  Note that

 aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
    [:class|
    {class. class class} do: aBlock

is not equivalent to 

    aClass theNonMetaClass withAllSuperAndSubclassesDoGently: aBlock
    aClass theNonMetaClass class withAllSuperAndSubclassesDoGently: aBlock

because the latter searches Behavior, ClassDescription, Class etc, while the former doesn't.

and just to be clear, I'm not claiming one way is better or not.
--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: SystemNavigation >> #allMethodsSelect:localTo:

Frank Shearar-3
On 21 May 2013 22:54, Eliot Miranda <[hidden email]> wrote:

>
>
> On Tue, May 21, 2013 at 2:53 PM, Eliot Miranda <[hidden email]>
> wrote:
>>
>>
>>
>> On Tue, May 21, 2013 at 2:40 PM, Frank Shearar <[hidden email]>
>> wrote:
>>>
>>> allMethodsSelect: aBlock localTo: aClass
>>>     "Answer a SortedCollection of each methodr in, above, or below the
>>> given
>>>     class that, when used as the argument to aBlock, gives a true
>>> result."
>>>
>>>     | aSet |
>>>     aSet := Set new.
>>>     Cursor wait showWhile:
>>>         [aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
>>>             [:class |
>>>                 class selectorsAndMethodsDo:
>>>                     [:aSelector :aMethod|
>>>                         (aBlock value: aMethod) ifTrue:
>>>                             [aSet add: (MethodReference new
>>> setStandardClass: class methodSymbol: aSelector)]]].
>>>         aClass theNonMetaClass class withAllSuperAndSubclassesDoGently:
>>>             [:class |
>>>                 class selectorsAndMethodsDo:
>>>                     [:aSelector :aMethod|
>>>                         (aBlock value: aMethod) ifTrue:
>>>                             [aSet add: (MethodReference new
>>> setStandardClass: class methodSymbol: aSelector)]]]].
>>>     ^aSet
>>>
>>> Um. That is just an accidental duplication of the aClass
>>> theNonMetaClass class withAllSuperAndSubclassesDoGently: block, right?
>>
>>
>> No, it's not :)  It's preserving existing behavior, which is to search
>> class and instance side.  Note that
>>
>>  aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
>>     [:class|
>>     {class. class class} do: aBlock
>>
>> is not equivalent to
>>
>>     aClass theNonMetaClass withAllSuperAndSubclassesDoGently: aBlock
>>     aClass theNonMetaClass class withAllSuperAndSubclassesDoGently: aBlock
>>
>> because the latter searches Behavior, ClassDescription, Class etc, while
>> the former doesn't.
>
>
> and just to be clear, I'm not claiming one way is better or not.

Ah! I had missed that single token!

frank

> --
> best,
> Eliot
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: SystemNavigation >> #allMethodsSelect:localTo:

Eliot Miranda-2


On Tue, May 21, 2013 at 2:55 PM, Frank Shearar <[hidden email]> wrote:
On 21 May 2013 22:54, Eliot Miranda <[hidden email]> wrote:
>
>
> On Tue, May 21, 2013 at 2:53 PM, Eliot Miranda <[hidden email]>
> wrote:
>>
>>
>>
>> On Tue, May 21, 2013 at 2:40 PM, Frank Shearar <[hidden email]>
>> wrote:
>>>
>>> allMethodsSelect: aBlock localTo: aClass
>>>     "Answer a SortedCollection of each methodr in, above, or below the
>>> given
>>>     class that, when used as the argument to aBlock, gives a true
>>> result."
>>>
>>>     | aSet |
>>>     aSet := Set new.
>>>     Cursor wait showWhile:
>>>         [aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
>>>             [:class |
>>>                 class selectorsAndMethodsDo:
>>>                     [:aSelector :aMethod|
>>>                         (aBlock value: aMethod) ifTrue:
>>>                             [aSet add: (MethodReference new
>>> setStandardClass: class methodSymbol: aSelector)]]].
>>>         aClass theNonMetaClass class withAllSuperAndSubclassesDoGently:
>>>             [:class |
>>>                 class selectorsAndMethodsDo:
>>>                     [:aSelector :aMethod|
>>>                         (aBlock value: aMethod) ifTrue:
>>>                             [aSet add: (MethodReference new
>>> setStandardClass: class methodSymbol: aSelector)]]]].
>>>     ^aSet
>>>
>>> Um. That is just an accidental duplication of the aClass
>>> theNonMetaClass class withAllSuperAndSubclassesDoGently: block, right?
>>
>>
>> No, it's not :)  It's preserving existing behavior, which is to search
>> class and instance side.  Note that
>>
>>  aClass theNonMetaClass withAllSuperAndSubclassesDoGently:
>>     [:class|
>>     {class. class class} do: aBlock
>>
>> is not equivalent to
>>
>>     aClass theNonMetaClass withAllSuperAndSubclassesDoGently: aBlock
>>     aClass theNonMetaClass class withAllSuperAndSubclassesDoGently: aBlock
>>
>> because the latter searches Behavior, ClassDescription, Class etc, while
>> the former doesn't.
>
>
> and just to be clear, I'm not claiming one way is better or not.

and writing it putting the block in a variable (as you did with another method last week, the future: one IIRC) makes the intention far clearer.

Ah! I had missed that single token!

frank

> --
> best,
> Eliot
>
>
>




--
best,
Eliot