[Q, BUG?] perform:orSendTo problem?

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Mon Nov 1 08:55:57 UTC 1999


On Sat, 30 Oct 1999, Jason McVay wrote:

> hello again all--
> 
> i asked about this last week and only heard from one person (thanks
> Torsten). however, i would like to hear from some others on this on if this
> is a bug or not.
> 
> from what i understand of the #perform: selector orSendTo: otherTarget
> method in both Object and Model, the receiever is supposed to be asked first
> if it can handle the selector; if not, then the selector is passed off to
> otherTarget. the comments in both classes says this is supposed to happen,
> but the implementation in both classes seems not to ask the receiever
> anything; instead, it just sends the selector onto otherTarget.
> 
> other classes such as PluggableText, StringHolder, and TranscriptStream
> override this method to what looks to be the proper implementation.
> 
> why is the message implemented like this in Object and Model? what am i
> missing?

AFAIK, #perform:orSendTo: is only used in menu dispatching code - it's not
an extended general #perform: (otherwise it should be disallowed to be
overidden in subclasses). So if by default the otherTarget should handle
everything, it is implemented correctly. However, this behaviour is highly
counter-intuitive.

So my proposal is:
  1.	rename all current references and implementations from
	perform:orSendTo: to #handle:orSendTo: which makes the intent
	clear. (maybe #intercept:defaultHandler: is even better). 
  2.	implement Object>>#perform:orSendTo: as you suggested (if needed
	at all - this could silently break some code. Maybe another
	selector would be better, like #perform:ifNotUnderstood:).

  /bert





More information about the Squeak-dev mailing list