[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefinedSelector question




> Why doesn't the 'undefinedSelector:...' run-time message include the
> sender as one of it's arguments?
> Wouldn't this allow some interesting things to be done 
> (e.g. implementing subjectivity)

Dunno about Self ('coz I haven't got a Sparc Ultra 9 zillion++ on which to
run it ;-) but it's trivial in Smalltalk.  I presume there's some easy way in
Self to do the equivalent of the following.

FWIW: load this into PS, instantiate a FooBar, and send it a message that it
doesn't understand: e.g. "FooBar new truncated".  The sender is identified
(correctly) as "nil".  When you do "FooBar new zonk", the #zonk method sends
self an unknown message, and the sender is identified (correctly) as "a
FooBar".  This works because you're guaranteed to have no intermediate
contexts between the context which sent the bad message and the resulting
invocation of #doesNotUnderstand:...


'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 25 July 1996 at 3:51:23 pm'!

Object subclass: #FooBar
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Zonkable Classes'!


!FooBar methodsFor: 'zonking'!

doesNotUnderstand: aMessage
	Transcript
		cr;
		show: 'funny message sent from ';
		show: thisContext sender receiver printString!

zonk
	^self reallyZonk! !


Ian

------------------------------- projet SOR -------------------------------
Ian Piumarta, INRIA Rocquencourt,          Internet: Ian.Piumarta@inria.fr
BP105, 78153 Le Chesnay Cedex, FRANCE         Voice: +33 1 39 63 52 87
----------------------- Systemes a Objets Repartis -----------------------