[Python-ideas] Message passing syntax for objects

Mark Janssen dreamingforward at gmail.com
Mon Mar 18 05:07:56 CET 2013


>> I think we should co-opt C++'s poorly used >> and << I/O operators
>> (for files) and re-purpose them for objects/classes.  One could then
>> have within interpreter space, the ability to pass in a message to an
>> object.
>>
>>>>>  42 >> MyObject  #sends 42 as a message into MyObject
>>
> What then happens to the binary shift operators: >> and <<? Those are
> defined by __rshift__ and __lshift__ (respectively) on an object
> already (help(int)). You could co-opt those operators with those
> methods on your object but that would probably confuse plenty of
> people.

Ah right.  But then, the shift operators pale in comparison to a
uniform way of passing messages between objects.

By building it into the language, it would *enforce* a modular object
style, rather than the current, very specialized and very programmer
specific way there is now.  In fact, most people never really think in
that paradigm, yet if the language supported/proposed such a syntax,
programmers would start to re-arrange the whole object hierarchy in a
new, more modular and universal way.

mark



More information about the Python-ideas mailing list