Metaclasses and co.

Bergel, Alexandre Alexandre.Bergel at cs.tcd.ie
Thu Feb 16 18:37:20 UTC 2006


Today I spend some time to read and understand an old mail from  
Andreas (http://lists.squeakfoundation.org/pipermail/squeak-dev/2005- 
October/096370.html) about having a parallel metaclass hierarchy. I  
really like this.

Thanks Andreas!!

I wrote a short test to understand it, I think it might interest some  
of you:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
testClassCreation
	"self debug: #testClassCreation"
	| mcls cls |

	mcls := MyMetaclass
		subclass: #MC
		instanceVariableNames: ''
		classVariableNames: ''
		poolDictionaries: ''
		category: 'MyMetaClassesGenerated'.
	cls := MyObject
		subclass: #C
		instanceVariableNames: ''
		classVariableNames: ''
		poolDictionaries: ''
		category: 'MyMetaClassesGenerated'
		metaclass: mcls.
	classCreated addAll: {mcls . cls}. "Used in teardown to remove the  
classes"
	
	mcls compile: 'foo ^20'.
	
	self assert: (cls new class == cls).
	self assert: (cls class name = 'C class').
	self assert: (cls class class == mcls).
	self assert: (cls class class class class == MyMetaclass).
	self assert: (cls class soleInstance == cls).

	self assert: (cls canUnderstand: #foo) not.
	self assert: (cls class respondsTo: #foo).
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






More information about the Squeak-dev mailing list