[Q] executing SOME compiledMethod (classless)

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Fri Mar 31 17:54:52 UTC 2000


Peter Novak wrote:

> We are working on
> prototypes in Squeak.

Great, finally someone's doing this. Let's hope you actually finish it. This
is such a commendable effort that I think if you just succeed to convince us
all that you're serious enough :) , you'll garner a good deal of support and
interest from others--in part I am thinking of myself here; please tell us
more about the whats and whys of your project!


Regarding your question of classless methods, which now turns out to be the
question of classless objects in general I suppose. (Forgive me if my
answers are on the wrong level--I don't know how much you already know about
these issues.)

> We need something like executing SOME byteCode without having it installed in
> any class.

One quick and dirty approach used in Smalltalk is to use Behaviors directly,
instead of full-blown classes. But this does give you an extra Behavior
object per object. It will get you part of the way however.

There is a somewhat niftier approach too: If you make the prototype
(classless object) inherit from Behavior (hey--it has to have a class in the
object header), then you can install the method directly into the object
itself. I think there are some VM dependencies that tie methods to Behavior,
but for the final answer you should consult Yoda himself. I may be wrong
here, I don't know the primitives well enough, but you may not even need to
install the CompiledMethod into a method dictionary. (Err, and welcome to
the world of Behavior, ClassDescription, Metaclass, and friends--the dark
side of the image.)

Referring to what Bob said, you'd have self point to this object as well.

I feel like I'm repeating myself from previous posts now, but this is not
the lion's share of the work, as one would think. Wait till you try to use
the browser together with your new scheme... The following sentence rang a
bell:

> We want to have in our prototype based system as few bindings to Smalltalk
> class system as it will be possible.

The browser code and logic is very hard-wired to the current class system
and inheritance scheme.


But to approach a more final answer to your question about prototypes &
methods, you must consider how inheritance (or what you choose to call
it--delegation etc.) should work with your prototypes. That is the real
issue. The present hard connection between method execution and classes (or
behaviors really) is a consequence of the current inheritance system.

If you haven't already thought about this, I suggest that you study the Self
approach, and it would be great if you adopted that approach too. It would
spare you from doing the same thiking all over again.

Henrik






More information about the Squeak-dev mailing list