[Python-ideas] Message passing syntax for objects

Steven D'Aprano steve at pearwood.info
Tue Mar 19 01:39:05 CET 2013

On 19/03/13 07:24, Mark Janssen wrote:

>>>>>> 42 >> MyCollectionType  #would add the object into your collection:
>>> >>  *poof*: no more random syntaxiis for putting things in collections.\
>> >
>> >So you've replaced one method of a collections API by your magical operator,
>> >for all collections.
> Yes -- for all collections.  That's a pretty big gain right?

No, not at all. If it's a gain at all, it's a tiny, microscopic gain. But it's not a gain. We lose a lot:

- we can no longer distinguish between *adding* something to an unordered collection, and *appending* to an ordered collection;

- we can no longer distinguish between (for example) *appending* to the end of a list, *extending* a list with a sequence, and *inserting* somewhere inside a list.

- we cannot even distinguish between "put this thing in your collection" and "search your collection for this thing", since we're limited to a single >> "send message" operator.

But please don't let me discourage you. I am actually very interested in a message passing idiom, I just don't think that it is as big a fundamental paradigm shift as you appear to believe. Way back in the late 1980s, I spent a lot of time working with a language that used a message passing paradigm, Apple's Hypertalk (part of Hypercard, which was strongly influenced by Alan Kay and Smalltalk). Hypertalk is long gone now, but you can get a feel for it with something like OpenXION:


I encourage you to see how message passing paradigms operate in existing other languages, such as OpenXION, and to come up with examples of syntax for simple tasks. E.g. what syntax would you use for something like this?

* Get a file name from the user.
* Open a file with that name.
* Read the text of that file.
* Convert the text to lowercase.
* Write it back out to the same file.

At the moment, I couldn't even begin to imagine how I might write that code using your syntax, let alone how it would be an improvement.


More information about the Python-ideas mailing list