AW: [newbie] perform:orSendTo:
Torsten.Bergmann at phaidros.com
Torsten.Bergmann at phaidros.com
Wed Oct 27 12:15:27 UTC 1999
An interesting question. Seems to be a bug.
I would implement it like the following (maybe "otherwise" is better than
"or"):
Object>>perform: selector otherwiseSendItTo: anotherObject
^self perform: selector otherwiseSend: selector to: anotherObject
Object>>perform: selector otherwiseSend: anotherSelector to: anotherObject
(self respondsTo: selector)
ifTrue: [^ self perform: selector]
ifFalse: [(anotherObject respondsTo: anotherSelector)
ifTrue: [^otherTarget perform:
otherSelector]
]
Think about this for unary messages:
Object>>perform: selector otherwiseDo: aBlock
Object>>perform: selector and: anotherSelector
Object>>performInOrder: anArrayOfSelectors
Object>>perform: selector andSendItTo: anotherObject
-Torsten
-----Urspr¸ngliche Nachricht-----
Von: Jason McVay [mailto:jmcvay at ipa.net]
Gesendet am: Wednesday, October 27, 1999 1:21 PM
An: squeak
Betreff: [newbie] perform:orSendTo:
hello all--
in Object>>perform:orSendTo:, i don't understand why the code is
Object>>perform: selector orSendTo:otherTarget
^ otherTarget perform: selector
instead of:
perform: selector orSendTo:otherTarget
(self respondsTo: selector)
ifTrue: [^ self perform: selector]
ifFalse: [^ otherTarget perform: selector]
it seems that the Object>>perform:orSendTo: doesn't give 'self' the
opportunity to respond to the #selector message. can someone explain this to
me?
thanks in advance
jason
More information about the Squeak-dev
mailing list
|