[Python-ideas] Message passing syntax for objects

Ian Cordasco graffatcolmingov at gmail.com
Tue Mar 19 16:58:22 CET 2013

On Tue, Mar 19, 2013 at 11:33 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> I don't disagree with you, Nick, but I don't think that's what the OP is
> looking for, either.  Even using call syntax, it seems to me the OP would
> still
> only be sending one type of message, with no arguments, no differentiation,
> no choices.

I understand OP wants to be able to send anything, but he seems to be
disregarding how << and >> are currently implemented on objects (via
__lshift__ and __rshift__ respectively). Each of those can be made in
a custom fashion by OP (or anyone else) but the question then becomes,
how do you add extra parameters (assuming you want them), i.e., how do
you do:

  obj << 4, *extra_args

I think (because I don't have a way of testing it right now) that
you'd get an error for trying to expand extra_args in the creation of
a tuple, regardless of the signature of __lshift__. Even if you didn't
do that, I think python would interpret that as the creation of a
tuple, i.e., the result of obj << 4 with the rest of the arguments.

> To use the OP's own example:
>    some_collection(42)
> would add 42 to the collection... but we have no say in where, or how.  In
> fact,
> using call() notation we have less than the OP's proposal as his proposal
> has a
> one-way in and a one-way out, but an argument-less* call can only provide
> one of
> those two options.
> --
> ~Ethan~
> *By argument-less I mean we can only give one thing to call.

And if we do this with the current implementation of python you can
still only give one thing to call (assuming I'm correct with my above
example). We would have to fundamentally change python and how it
interprets those special cases (again basing the statement on my above
assumptions/intuition). I'm sure in another language I would find this
feature to be interesting or even appreciate it, but I don't think it
is either very pythonic or useful in python. I'm also wondering if
this is just a very well done troll since OP has yet to back any of
his own examples which he thinks others are choosing to make his life

More information about the Python-ideas mailing list