Python Macros
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Oct 5 04:14:16 EDT 2004
Josiah Carlson wrote:
>>Not sure I understand you here. I want to implement messages like in
>>ObjC where if you send a msg to an object and that object does know what
>>to do with it, it can send the obj automatically to another object which
>>might know what to do with it.
>>
>>Anyhow, there are other reasons as well.
>
>
> What are called "messages" in ObjC, are generally known as "instance
> methods" in Python.
>
> I would imagine in ObjC you would do something like the following:
>
> object.send('operation', arg1, arg2, arg3,...)
> send(object, 'operation', arg1, arg2, arg3,...)
>
> In Python, that becomes:
>
> object.operation(arg1, arg2, arg3,...)
>
>
> "Messages" in ObjC are really just a metaphor, one that is shared by
> Smalltalk, but not many other object-oriented languages.
>
Well, I'd rather say that *all* OOPLs support message passing. What we
call 'methods' are just a way to implement a specific response to a message.
Given the following code :
"a b c d".split()
What we're really doing - from an OO POV - is not calling the split()
instance method of class str, but sending the 'split' message to a str
object. The fact that doing so result in calling the split() instance
method of the str class is just a side effect !-)
just-playing-with-words-ly y'rs
Bruno
More information about the Python-list
mailing list