[Newbies] Message/Method

Bert Freudenberg bert at freudenbergs.de
Tue Dec 5 20:02:03 UTC 2006

On Dec 5, 2006, at 12:00 , Bert Freudenberg wrote:

> On Dec 5, 2006, at 11:52 , Blake wrote:
>> 	I'm not sure whether to ask this here or on the main list, but I  
>> thought I'd start here.
>> In a traditional 3GL with objects bolted on, methods are  
>> subroutines with a hidden "self" parameter, so if I write (using,  
>> oh, Object Pascal):
>> MyObject.MyMethod;
>> I know that MyObject is of a class that has a method (or an  
>> ancestor with a method) called MyMethod.
>> 	I have read things on Smalltalk that suggest to me that:
>> myObject myMethod.
>> the selector "myMethod" does not necessarily map one-to-one with a  
>> method named "myMethod".
>> 	But I haven't been able to figure out how that could be, or under  
>> what situation it would be useful.
> The difference is that you can send any message to any object, and  
> the object's class can decide how to handle that method.

I meant to write "... to handle that *message*" of course ;)

> By default, the class looks into the dictionary of all defined  
> methods and invokes the matching method. But it can also decide to  
> handle *any* message, regardless of which methods are actually  
> defined. This lets you implement, for example, generic object  
> wrappers that log any message sent to an object. Or, forward the  
> message over the network to another image. Or, which is the normal  
> case, raise an exception that this message was not understood.
> - Bert -

More information about the Beginners mailing list