[Python-ideas] Message passing syntax for objects

Lele Gaifax lele at metapensiero.it
Mon Mar 18 15:16:31 EDT 2013


88888 Dihedral <dihedral88888 at googlemail.com> writes:

> zipher於 2013年3月19日星期二UTC+8上午1時04分36秒寫道:
>> the key conceptual shift is that by enforcing a syntax that moves
>> away from invoking methods and move to message passing between
>> objects, you're automatically enforcing a more modular approach.
>
> Please check object pascal and objective c and erlang for 
> the message-action director model of what you want.

I fail to see how syntax differences would change the modularity of your
product. 

The fact that (say) ObjC use the name "message" while Python calls the
same a "method" isn't actually changing the concrete fact that both are
executing some sort of function that accepts an "instance" object as one
of the arguments (in Python, the first parameter, usually called self,
in ObjC, and implicit "self").

In other words, the following ObjC

  [someObj getItemAt: i]

is perfectly equivalent to the following Python

  someObj.getItemAt(i)

and to the following Smalltalk

  someObj getItemAt: i

How is the former syntax, where "getItemAt:" is called a "message", more
modular from the second, where "getItemAt()" is called a method?

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list