Metaprogramming in Squeak

Comments

You can even set an object to be its own class, and hence get real prototype-oriented instances on Squeak.

oroboros := Class new.
oroboros superclass: Class. oroboros methodDictionary: MethodDictionery new. oroboros setFormat: Class format. oroboros primitiveChangeClassTo: oroboros basicNew
oroboros class = oroboros --> true

More see here http://smallwiki.unibe.ch/adriankuhn/protalk/
Wow! Thanks a lot for this. A while back I was poking around inside Squeak to try to find out how to dynamically compile code. I already knew about Compiler evaluate:, which I could use to compile a BlockClosure, for example. During my search I kept running into the Behavior class, but I didn't know what it really represented or what it could do. I was also running into methods to compile methods, but I didn't see any examples of how to use them. As descriptive as Smalltalk code is, unfortunately it's not always self-explanatory. Examples help.

Post a comment

Already a Vox member? Sign in

Randal Schwartz

About Me

Randal Schwartz
United States
Just another [insert technology here] hacker!
Jaiku:
merlyn

My Groups

Neighborhood

Explore friends, family, friends & family, or entire neighborhood.

Archives