Antwort: Mixed feelings

Ian Piumarta ian.piumarta at inria.fr
Mon Jun 10 07:17:45 UTC 2002


On Sun, 9 Jun 2002, Tim Rowledge wrote:

> >   Not every object wants to know how to present itself in HTML.
> Depends on your web framework. PWS/Comanche/Swikie/etc actually allow 
> any object to present itself to the browser user. To do that you have to 
> have some sort of interface up in Object to make sure it will work.

1. File this in.
2. Open a transcript and a workspace.
3. evalute this in the workspace:

	Subject new test: 42

4. Quit your image without saving.
5. Go figure.

Of course, any half-serious implementation would:

- store the subject methods in a real dictionary
- perform real lookups on that dictionary instead of explicit tests
- propose some kind of friendly "compile (in a remote class),
  install, remove" interface
- provide a way to browse the subject methods
- hack on Interpreter for a couple of hours to add VM support so
  it runs as fast as normalSend

Ian
-------------- next part --------------
'From Squeak3.2gamma of 15 January 2002 [latest update: #4857] on 7 June 2002 at 11:28:47 pm'!
Object subclass: #Subject
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'SOP'!

!Object methodsFor: 'error handling' stamp: 'ikp 6/7/2002 19:17'!
doesNotUnderstand: aMessage 
	 "Handle the fact that there was an attempt to send the given message to the receiver but the receiver does not understand this message (typically sent from the machine when a message is sent to the receiver and no method is defined for that selector)."
	"Testing: (3 activeProcess)"

	| subject subjectMethod |
	(Preferences autoAccessors and: [self tryToDefineVariableAccess: aMessage])
		ifTrue: [^ aMessage sentTo: self].

	(((subject _ thisContext sender receiver) class includesSelector: #subjectMethodFor:at:)
			and: [(subjectMethod _ subject subjectMethodFor: self class at: aMessage selector) notNil])
		ifTrue: [^subjectMethod valueWithReceiver: self arguments: aMessage arguments].

	MessageNotUnderstood new message: aMessage;
		signal.
	^aMessage sentTo: self! !


!Subject methodsFor: 'as yet unclassified' stamp: 'ikp 6/7/2002 19:15'!
subjectMethodFor: aClass at: aSelector

	(aClass == SmallInteger and: [aSelector == #toto])
		ifTrue: [^self class compiledMethodAt: #totoSmallInteger]
		ifFalse: [^nil]! !

!Subject methodsFor: 'as yet unclassified' stamp: 'ikp 6/7/2002 19:16'!
test: anObject

	^anObject toto! !

!Subject methodsFor: 'as yet unclassified' stamp: 'ikp 6/7/2002 19:15'!
totoSmallInteger
	Transcript show: 'toto for ' , self printString! !



More information about the Squeak-dev mailing list