4 ms·
As a counterpoint, I would suggest looking at Jeff McAffer's CodA project. It defined a group of 7 metaobjects to define the behavior of each object, six of the
by jecel 4y ago
As a counterpoint, I would suggest looking at Jeff McAffer's CodA project. It defined a group of 7 metaobjects to define the behavior of each object, six of them for message passing and one for accessing state. He couldn't patch the commercial VisualWorks virtual machine and used #doesNotUnderstand: tricks to make his prototype work. It wasn't fast, but showed that the semantics were correct. Here are the message passing metaobjects he defined:
- Send: prepares a message to be sent and negotiates with the receiver
- Accept: negotiates with the sender
- Queue: can save accepted messages to be handled later
- Receive: deals with queued messages
- Protocol: can associated the selector in a message with executable code
- Execution: knows how to used system resources to actually do what the message asked
The default metaobjects are 100% compatible with Smalltalk-80 base level code but his thesis show several interesting alternatives.
- Rochus 4y agoThere is no doubt that you can implement a message passing system in Smalltalk, as you can with any Turing complete language. In Smalltalk instead of "calling a virtual method" people just say "sending a message". But it actually works quite similar like e.g. the Java VM. Params and receiver object are evaluated and pushed to the stack, then the method is looked up in the receiver class using the selector (which is an internalized string) and then calls the method with the given parameters (this lookup and call is called "send" in Smalltalk); the major difference is that in Java the verifier checks whether a method with the given name and signature actually exists in the class when it is loaded; but also in Java you can influence the dispatch as you described and e.g. create your own class loader.
- jecel 4y agoWhile you can implement message passing on top of any language, as you said, I was talking about doing message passing under Smalltalk-80. There are non messaging parts in Smalltalk-80, like assignment. The Self variant of Smalltalk goes quite a bit further in using message passing for everything.