Greetings! I am implementing a Java VM in Squeak, and am trying to figure out how to represent Java concepts in Smalltalk. Here's the idea I had so far:
1) Create Squeak classes for everything that needs to be represented (e.g. JavaClass, JavaInterface, &c.). 2) Instances fo these classes would be Java classes. So if Java had class Foo, then Foo would be an instance of the JavaClass class. These would have to be, I assume, singletons. 3) Instances of instances... ? Now this is where I thought of metaclasses. I recall that in the first Smalltalk paper I read it was mentioned that all Smalltalk classes are instances of their respective metaclass, and that metaclasses are in turn instances of metaclass-class. So I was hoping to change 1) to be metaclasses... then 2) would be classes, and instances of these would be, well, instances. Is this feasible? Or would it be possible to make the instances of the classes in 1) behave like classes in turn (that is, make instances of the instances in 2) )?
In short, I'm thinking of 2 solutions to the problem presented above: - To make a metaclasses for the Java concepts. While this makes it easier for me an those I work with to wrap our heads around, it seems like a waste (Since in that case the Java classes would each be represented by a Smalltalk class). - To have instances of a class behave like classes themselves. This feels 'more right', but I'm afraid that I'm not experienced enough with Squeak to know how this is to be done (and if it is even possible). Could anyone give me some hints regarding this (perhaps direct me to the right paper/site covering these topics?).
Regards.... -CWS
Hi Calus,
Claus Spitzer wrote:
Greetings! I am implementing a Java VM in Squeak, and am trying to figure out how to represent Java concepts in Smalltalk.
If you're trying to reimplement Java on-top of Squeak then you don't need to worry about metaclasses. For every concept in Java just implement a class. You'll probably need to have a class for representing java.lang.Class. But, actually, this not not a true metaclass. Or, at least it does not need to be implemented so... You only need to provide somehow (class instance variable) the same instance of java.lang.Class as the answer when the message getClass() is sent to instances of a same class.
Instances of java.lang.Class should point to application classes to allow introspection and instance creation.
Noury ------------------------------------------ Dr. Noury Bouraqadi - Enseignant/Chercheur Ecole des Mines de Douai - Dept. G.I.P http://csl.ensm-douai.fr/noury
European Smalltalk Users Group Board http://www.esug.org
Squeak: an Open Source Smalltalk http://www.squeak.org ------------------------------------------
squeak-dev@lists.squeakfoundation.org