3 ms·
I disagree, not because methods do not get called, but because the Smalltalk sender is not calling a method, it is sending a message. It says to the runtime, h
by projektfu 3y ago
I disagree, not because methods do not get called, but because the Smalltalk sender is not calling a method, it is sending a message. It says to the runtime, here is an object and I want to send "#collect:" to it using this other object obj as a parameter. The runtime looks in the object's class for a method called "collect:" and, if found, calls the method with the receiver and obj. If not found, it will look in the superclasses until it cannot find it, then it will send "#doesNotUnderstand:" with the context, and go up the class hierarchy again. Because of the message-passing paradigm, the receiver can make behaviors that are unusual, such as proxying and delegation, in a more or less transparent fashion.
If the sender is calling a method, then that is a static arrangement and the result is not different from a function call.
- vanviegen 3y agoHow does what you're describing differ from polymorphism, or from doing OOP in loosely typed languages like javascript?
- fzzzy 3y agoEvery single object in smalltalk is free to have its own implementation of handling a message. In javascript, the runtime decides for the object how to locate the code and how to call it.