[ENH request] self class.
Lukas Renggli
renggli at iam.unibe.ch
Thu Oct 14 13:33:10 UTC 2004
>>>> Would it be possible to rename the primitive Object>>class to
>>>> Object>>basicClass, and then implement Object>>class as:
>>>
>>> In many Smalltalks, you can't override #class. Squeak is one of
>>> those --
>>> you can comment out the primitive call in Object >> #class, and
>>> everything
>>> still works fine. The compiler short-circuits the message, and just
>>> answers
>>> the class (or something like that).
>>
>> I once did something similar: you can remove #class from the
>> special-selectors collection in the compiler (class-var StdSelectors
>> in ParseNode). From then on all methods you compile actually send the
>> message #class and therefor it can also be overridden.
>
> Oh, it's not in the VM - good. Markus, does the new Compiler package
> still have this? Can we get rid of it?
Well, it is in both, the VM and the compiler. There are special
byte-codes for selectors like #class, #at:, #<=, etc. That's also why
these selectors never appear in the literal-frame of a method. So
obviously the VM does directly push the class onto the stack, when
processing the #class-byte-code. If you tell the compiler not to emit
this special byte-code (as explained above), but the standard
message-send-byte-code, there is no optimization of the VM going on.
Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch
More information about the Squeak-dev
mailing list
|