Does #class deserve to be a very-special shortcut bytecode anymore?

Stephen Pair spair at advantive.com
Sat Jan 5 15:58:25 UTC 2002


Randal L. Schwartz wrote:
> Or "class" and "basicClass", following the "new" and 
> "basicNew" pattern, with ProtoObject defining class as "^self 
> basicClass", and basicClass spitting out the inline special 
> bytecode, but class no longer being a special.

Actually, having the bytecode is not the problem...it's the fact that
the implementation of the bytecode doesn't actually do a message send
(as most (if not all) other bytecoded messages do).  If it did an actual
message send, we could easily do the #class and #basicClass thing, but
just make both of them be the class primitive (primitive: 111...just as
size and basicSize currently work)...it's interesting that that primtive
is hardly ever used, I guess the only way to use it is through one of
the #perform: variants.

I think Andreas' suggestion of having a special primitive to get the
non-forged class is a good idea for cases where that's what you need.
But I guess you'd have to have the primitive work on a parameter and not
the receiver (otherwise, the existing primitive would work just fine).
I'd even take this a step further and make the class accessible through
a mirror based reflection scheme.  This would allow you to get at the
class (and other things) without having to invoke an actual method, but
still offer encapsulation through the mirror.  All of the #instVarAt:,
#instVarAt:put:, and other such methods could be accessible through a
mirror and removed from Object's protocol.

- Stephen





More information about the Squeak-dev mailing list