Re: [Pyobjc-dev] Calling methods on nil
Brought to you by:
ronaldoussoren
From: Marcel W. <ma...@me...> - 2003-05-11 06:00:58
|
On Friday, May 9, 2003, at 09:48 Uhr, Just van Rossum wrote: > Marcel Weiher wrote: > >>> Bad example (I'm calling _this_ method on _that_ instance, I don't >>> see what's implicit about that), >> >> Well, you aren't "calling" a "method" on an instance. You are sending >> a message to that instance, and that's not just a difference in >> wording, although getting the terminology right also generally helps. > > That's just a matter of perspective. That turns out not to be the case. > In Objective-C you call it "sending > a message to an instance", in Python we call it "calling a method". Well, then you say it wrong "in Python". Seriously, there are other things you could call it, but "calling a method" is definitely not all that is happening. "Calling a method" would be correct if you already *had* the method and just invoked it. But that isn't what is happening: > The mechanics differ, but it's the same thing (OO with dynamic method > dispatching). Exactly. There is dynamic dispatch. So when you "send a message", you get dynamic dispatch, and THEN the method is called. If you just say "the method is called", you are simply *verbally* omitting the dynamic dispatch, though of course it is still happening. Of course, this just re-enforces my point that the dynamic dispatch of message sending is *implicit* in OO [it is being done, but it is not mentioned *explicitly* in the program code]. You seem to have even edited it out of your mental-model! ;-) > PyObjC demonstrates that clearly. Very clearly! > However, the differences in the mechanics between Python and > Objective-C > make that "sending messages to nil" is a viable construct in > Objective-C, but not in Python. > > (I agree with you there's some implicity involved in method calling, > it's just that it doesn't feel that way to me since the rules are > clearly defined.) Exactly my point, thank you! :-) The fact that it doesn't *feel* like that any longer for you just shows how implicit message sending (or dynamic dispatch, if you prefer) has become. So it goes with ignoring messages to nil: the rules are very clearly defined (a lot simpler than messages to other receivers), so there is no "general principle" that is being violated. It is just that you are used to something different, and haven't assimilated these particular rules (yet ;-). Regards, Marcel -- Marcel Weiher Metaobject Software Technologies ma...@me... www.metaobject.com Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc. |