[Help-Smalltalk] Message>>#= and DirectedMessage>>#=

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

[Help-Smalltalk] Message>>#= and DirectedMessage>>#=

MrGwen
Message extend [
    = anObject [
        <category: 'testing'>

        ^ self class == anObject class and: [ self selector = anObject
selector and: [ self arguments = anObject arguments ] ]
    ]
]

DirectedMessage extend [
    = anObject [
        <category: 'testing'>

        ^ super = anObject and: [ self receiver = anObject receiver ]
    ]
]

Eval [

    | o1 m1 m2 |
    m1 := Message selector: #'a:b:c:' argument: #(1 2 3).
    m2 := Message selector: #'a:b:c:' argument: #(1 2 3).

    m1 = m2 ifFalse: [ self error: 'm1 should be equal to m2' ].

    m2 := Message selector: #'a:b:c:' argument: #(2 3 4).
    m1 = m2 ifTrue: [ self error: 'm1 should be different of m2' ].

    o1 := Object new.

    m1 := DirectedMessage receiver: 01 selector: #'a:b:c:' argument: #(1 2 3).
    m2 := DirectedMessage receiver: 01 selector: #'a:b:c:' argument: #(1 2 3).

    m1 = m2 ifFalse: [ self error: 'm1 should be equal to m2' ].

    m2 := DirectedMessage receiver: Object new selector: #'a:b:c:'
argument: #(1 2 3).
    m1 = m2 ifTrue: [ self error: 'm1 should be different of m2' ].
]

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Message>>#= and DirectedMessage>>#=

Paolo Bonzini-2
On 10/12/2010 11:02 AM, Gwenaël Casaccio wrote:

> Message extend [
>      = anObject [
>          <category: 'testing'>
>
>          ^ self class == anObject class and: [ self selector = anObject
> selector and: [ self arguments = anObject arguments ] ]
>      ]
> ]
>
> DirectedMessage extend [
>      = anObject [
>          <category: 'testing'>
>
>          ^ super = anObject and: [ self receiver = anObject receiver ]
>      ]
> ]

#hash missing.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Message>>#= and DirectedMessage>>#=

MrGwen
On Tue, Oct 12, 2010 at 11:42 AM, Paolo Bonzini <[hidden email]> wrote:
> On 10/12/2010 11:02 AM, Gwenaël Casaccio wrote:
>>
>> Message extend [
>>     = anObject [
>>         <category: 'testing'>
>>
>>         ^ self class == anObject class and: [ self selector = anObject
>> selector and: [ self arguments = anObject arguments ] ]
>>     ]

    hash [
        <category: 'basic'>

        ^ (super hash bitXor: self selector hash) bitXor: self arguments hash
    ]

>> ]
>>
>> DirectedMessage extend [
>>     = anObject [
>>         <category: 'testing'>
>>
>>         ^ super = anObject and: [ self receiver = anObject receiver ]
>>     ]

    hash [
        <category: 'basic'>

        ^ super hash bitXor: self receiver hash
    ]
>> ]
>
> #hash missing.
>
> Paolo
>

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Message>>#= and DirectedMessage>>#=

Paolo Bonzini-2
On 10/12/2010 11:53 AM, Gwenaël Casaccio wrote:

> On Tue, Oct 12, 2010 at 11:42 AM, Paolo Bonzini<[hidden email]>  wrote:
>> On 10/12/2010 11:02 AM, Gwenaël Casaccio wrote:
>>>
>>> Message extend [
>>>      = anObject [
>>>          <category: 'testing'>
>>>
>>>          ^ self class == anObject class and: [ self selector = anObject
>>> selector and: [ self arguments = anObject arguments ] ]
>>>      ]
>
>      hash [
>          <category: 'basic'>
>
>          ^ (super hash bitXor: self selector hash) bitXor: self arguments hash
>      ]
>
>>> ]
>>>
>>> DirectedMessage extend [
>>>      = anObject [
>>>          <category: 'testing'>
>>>
>>>          ^ super = anObject and: [ self receiver = anObject receiver ]
>>>      ]
>
>      hash [
>          <category: 'basic'>
>
>          ^ super hash bitXor: self receiver hash
>      ]
>>> ]
>>
>> #hash missing.

And maybe make a "real" patch and send it? :)

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk