Alan Gauld said unto the world upon 2004-12-20 09:27:

<SNIP helpful confirmation that I had understood a point about resolution of method calls across a class hierarchy -- my long question snipp'ed too>

Its another reason why you should never refer to
an object or method *calling* another method
(as Pilgrim does). Rather think of the method
sending a *message* to the self object which
invokes the appropriate method. This decoupling
of message from method is a vitally important
concept in OO and onvce you understand the concept
of messages being sent resulting in methods
being invoked OOD becomes much easier to grasp.
This is explicit in Lisp, Smalltalk and Objective C
where methods may have completely different names
to messages, and multiple messages may invoke the
same method - possibly with different default
parameters - a very powerful technique! it's just
about possible to do this in Python with lambdas
etc but its messy.

Alan G.

Thanks Alan.

I appreciate the confirmation of my stumblings towards understanding. On the plus side, after a few evenings of serious effort, I can't quite understand what about OOP and classes had me so intimidated before :-) (That said, I'm a long way off from having these things down.)

The contrast you suggest between calling a method and sending a message to an object isn't immediately clear to me. I'll put on my puzzling cap. But do you suggest it to emphasize that it is features of the object that determine which method gets invoked by the object.method() notation, or for some other reason? (By "features of the object" I mean things like facts about where the class that the object is a primary instance of falls in an inheritance tree.)

Thanks again,

Brian vdB

_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to