[GOODIE] Squeak Smalltalk: A Quick Reference (v. 0.0)

Bob Arning arning at charm.net
Sun Dec 5 18:55:57 UTC 1999


On Sun, 5 Dec 1999 19:28:33 +0100 Marcus Denker <marcus at ira.uka.de> wrote:
>Playing around with this i found some *very* strange thing:
>
>Do: (not print!):     a := ProtoObject new.  
>
>then print:           a class
>
>But "class" is only defined in Object(!), so an instance of ProtoObject
>can't respond to this message. But it does. Very strange...

That's one of those VM shortcuts whose existence sometimes fools us, but without which life would proceed at a much slower pace. A number of common message sends are actually compiled to their own bytecode. This can reduce the size of compiled methods and speed execution of really common stuff.

- some of these simply do a normal method dispatch 
- some of these actually do the intended work if the receiver (and arguments, if any) are of certain common type(s) and send a normal message only if this fails.
- some simply do the job without question. The bytecode for sending #class is one of these. You can even put a #halt in the #class method from Object and still have a running system (although you might have trouble if someone sent #class as the argument to #perform:). 

For further details, see the implementors of #bytecodePrim... in Interpreter.

Cheers,
Bob





More information about the Squeak-dev mailing list