4 ms·
What is the essential aspect that distinguishes a message from a call? According to Wikipedia, it's that the arguments are deep-copied, but that is not what hap
by extension 16y ago
What is the essential aspect that distinguishes a message from a call? According to Wikipedia, it's that the arguments are deep-copied, but that is not what happens in Smalltalk, AFAIK. It's also contradicted in another section where it says the arguments are "usually" copied. I would have thought the important part was late binding, which is indeed a requirement but apparently not divisive.
Edit: If this is any indication then I'm prepared to declare "message passing" a heisenterm, with no formal definition across all contexts:
http://stackoverflow.com/questions/43777/method-vs-message-vs-function-vs http://stackoverflow.com/questions/43777/method-vs-message-v...
- kd5bjo 16y agoA method call is two separate messages. One going to the object with the parameters, and another with the result. Note that even void-return functions involve two messages; in that case, the return message simply indicates completion of the function that is bound to the method.
- cubicle67 16y agoOne of the major differences, from a programming point of view (as opposed to implementation) is that with message passing, you can pass any message to an object, even if that object doesn't know how to handle it. Cocoa makes extensive use of delegates (not sure if these are similar to .net delegates) for handling unrecognised messages, which makes adding custom behaviour to classes possible without subclassing. Rails is (in)famous for making use of Ruby's method_missing to implement all sorts of funky stuff.
- lucifer 16y agoA call is invoking a known method bound to the object. In a call based system, the semantics of the object are defined by its interface. A message is invoking a universal message receiver method bound to all object. Semantics are determined by message content processing. (c.f. "meta boundaries"). It seems accurate then to say "message passing is a specialized form of method invocation that relies on a universal receiver method and delegates the invocation of object methods to the receiver.