Re: [Pyobjc-dev] Calling methods on nil
Brought to you by:
ronaldoussoren
From: Marcel W. <ma...@me...> - 2003-05-11 15:30:55
|
On Sunday, May 11, 2003, at 11:34 Uhr, Just van Rossum wrote: > Marcel Weiher wrote: > >>> 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. > > That's just a matter of perspective <wink>: to me "the method foo of > this object" means the method you'd get when dispatching. Yes. This means that you have *implied* a dispatching mechanism when you speak of "the method foo of this object". (You didn't mention it explicitly, but it is there -> implied). What about this is difficult? > Since dynamic > method dispatching is so deeply integrated in Python, I don't see how > it > could mean anything else, so I disagree I'm omitting something crucial. I am not saying that you are "omitting" anything. I am saying you are not mentioning *explicitly*, but *implicitly*. This behavior is implied by what you are saying. > I'm not arguing against sending messages to nil in ObjC (although I > don't like it, see below), but against supporting it by PyObjC in > *Python*. I have no problem with handling it one way or the other. I had a problem with the 'reasoning' you presented, which was quite wrong. > (Just yesterday I was working on some code where a (Cocoa) method > unexpectedly returned nil (translated to None in Python). I was > extremely happy to get a traceback instead of silent failure; since > None > is an actual object, it dispatches methods just like most other > objects, > ie. raise an exception if a method isn't found. A silent failure surely > would've cost me much more time to figure out what I did wrong. > Ignoring > messages to nil is convenient when you expect it, but it's a liability > when you don't. I much rather explicitly test for nil than shoot myself > in the foot.) Well, I am just as happy that I don't have to obscure my code with clutter... So there we are, two happy people ;-) Marcel -- Marcel Weiher Metaobject Software Technologies ma...@me... www.metaobject.com Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc. |