freb@ittvax.UUCP (Karl Freburger) (02/02/84)
I have a few questions about the way some messages are sent in Smalltalk-80. Certain selectors like + and - are special, and a message using one of these selectors uses a "Send Special Message" bytecode (see page 596 of "The Language and Its Implementation", bytecodes 192-207). The "sendSpecialSelectorBytecode" method on page 608 tries to by-pass the normal method lookup by invoking "specialSelectorPrimitiveResponse". If that succeeds, it means that a primitive was successfully executed (in the case of + and -, it means that the arguments were both SmallIntegers and the result was a SmallInteger). If it fails, the "normal" full method lookup is done. What about the special selectors like == and class? They will bypass the full lookup and invoke primitives which always succeed. I think this has at least two implications. First, if you redefine the method == or class in Object to do something other than just invoke the primitive, the primitive will still be invoked anyway. In other words, I don't think you could change the definitions of class and ==. Second, I don't think you could override == and class in subclasses of Object, for the same reason (not that you'd want to do that!). Am I understanding this correctly? On page 550, there is a statement that certain control structures are optimized using the jump bytecodes. These include ifTrue:, ifFalse:, and ifTrue:ifFalse: for Booleans, and: and or: for Booleans, and whileTrue: and whileFalse: for Blocks. Since the Smalltalk compiler cannot tell when a variable is holding a Boolean and when it's not, I assume that jump bytecodes are generated whenever an ifTrue: is used. I think this means that these selectors are "reserved" and can only be used in certain ways. If I had a class with a method ifTrue:, and the compiler was going to generate jump bytecodes, I'd be out of luck, wouldn't I? Does anyone know of a Smalltalk Virtual Machine implementation for the Sun? I might have real money to spend on one. The best case would be a company that was sub-licensing Smalltalk, but I'd consider just acquiring the VM and getting a Smalltalk license here. Thanks for any light anyone can shed on these questions. Karl Freburger decvax!ittvax!freb