#perform:#orSendTo: question
Alexandre Bergel
bergel at iam.unibe.ch
Tue Sep 21 11:20:48 UTC 2004
Stephan,
I do not understand.
If you have B subclass of A.
and B>>foo exists.
'B new perform: #foo orSendTo: whatever' will perform 'whatever foo'.
I agree with Sam. I will do a fix for that. But I remember that there was a long discussion about this point a while ago...
Alexandre
On Mon, Sep 20, 2004 at 06:29:53PM +0200, Stephan Rudlof wrote:
> Samuel,
>
> Samuel Tardieu wrote:
> > I wonder why the implementation of Object>>#perform:#orSendTo: looks
> > counterintuitive to me:
> >
> > perform: selector orSendTo: otherTarget
> > "If I wish to intercept and handle selector myself, do it;
> > else send it to otherTarget"
> > ^ otherTarget perform: selector
> >
> > I would have naively thought that a correct implementation was:
> >
> > (self respondsTo: selector) ifTrue: [ ^self perform: selector ]
> > ifFalse: [ ^otherTarget perform: selector ]
> >
> > Can I find somewhere an explanation of how this selector is supposed
> > to be used?
>
> If there is an implementation of selector, it resides in a *sub*class of
> Object and will be performed automatically, since the corresponding
> message will be send to the subclass corresponding to the receiver
> object first.
> On the other hand, if there is no *sub*class of Object implementing
> selector, the method in Object comes into play (method lookup goes from
> the subclass corresponding to the receiver up to Object).
>
>
> Greetings
> Stephan
>
> >
> > Sam
>
> --
> Stephan Rudlof (sr at evolgo.de)
> "Genius doesn't work on an assembly line basis.
> You can't simply say, 'Today I will be brilliant.'"
> -- Kirk, "The Ultimate Computer", stardate 4731.3
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel http://www.iam.unibe.ch/~bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
More information about the Squeak-dev
mailing list
|