Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41539

Re: [Python-ideas] Message passing syntax for objects

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:: [': 0.03; 'interpreter': 0.04; 'subject:Python': 0.05; 'binary': 0.05; 'method.': 0.05; 'exist,': 0.07; 'objects,': 0.07; 'raises': 0.07; 'suppose': 0.07; 'missed': 0.09; 'python': 0.09; 'interpreter,': 0.09; 'models.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'useless': 0.09; 'sfxlen:2': 0.10; 'def': 0.10; '(the': 0.15; '(but': 0.15; 'passing': 0.15; 'result.': 0.15; 'both.': 0.16; 'c.__len__': 0.16; 'effect,': 0.16; 'len(c)': 0.16; 'operator.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:ideas': 0.16; 'syntax,': 0.16; 'wrote:': 0.17; 'example.': 0.17; 'jan': 0.18; 'subject:] ': 0.19; 'int,': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'possibly': 0.27; 'andrew': 0.27; 'header:X-Complaints-To:1': 0.28; 'kay': 0.29; 'skip:_ 10': 0.29; 'usually': 0.30; 'could': 0.32; 'message.': 0.33; 'turns': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'add': 0.36; 'received:org': 0.36; 'programmers': 0.36; 'method': 0.36; 'should': 0.36; 'turn': 0.36; 'does': 0.37; 'usual': 0.37; 'fact': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'strange': 0.62; 'different': 0.63; 'behavior': 0.64; 'different.': 0.84; 'received:fios.verizon.net': 0.84; 'lists:': 0.91; 'obvious,': 0.91; 'preferred,': 0.91; '8bit%:18': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: [Python-ideas] Message passing syntax for objects
Date Tue, 19 Mar 2013 16:09:44 -0400
References <CAMjeLr_dBCSL9VGjrW6wJjMDhLWFdxWqGWw+5MXTfo8+x9yfYw@mail.gmail.com> <5146B848.3040509@pearwood.info> <CAMjeLr9bH9nYpEeq8KjzHXmEXpuUgAjvWb3f2e7VR2sno=6Rkw@mail.gmail.com> <CAMjeLr9f1wmFTYh7ShQrzc-fo+Xa5DPG-LDULn2VnUbrBjEo-Q@mail.gmail.com> <1363643500.25746.YahooMailNeo@web184701.mail.ne1.yahoo.com> <CAMjeLr-m5uOW95zSHMO-18i81dH4Es0OCpte-HEO_rCmV=dpWA@mail.gmail.com> <1363663891.8351.YahooMailNeo@web184701.mail.ne1.yahoo.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
In-Reply-To <1363663891.8351.YahooMailNeo@web184701.mail.ne1.yahoo.com>
Cc python-ideas@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3534.1363723808.2939.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363723808 news.xs4all.nl 6911 [2001:888:2000:d::a6]:40745
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41539

Show key headers only | View raw


On 3/18/2013 11:31 PM, Andrew Barnert wrote:

> The idea that message passing is fundamentally different from method
> calling also turned out to be one of those strange ideas, since it
> only took a couple years to prove that they are theoretically
> completely isomorphic—and,

Since the isomorphism is so obvious, I somehow missed that Kay actually 
thought that they were different. I suppose one could have different 
(but isomorphic) mental image models.

For me, the problem with message passing, as usually though of, or 
method calls in their usual syntax, is the breaking of symmetries such 
as the commutivity of number addition. I think of 'a + b' as a message 
to the interpreter, as supervisor of Python objects, to add a and b 
together and give me the result. It turns out that a Python interpreter 
does that by calling *either* a.__add__(b) or b.__add__(a) or possibly both.

The advantage of passing messages through a supervisor is that it can 
'supervise' the process. The behavior with binary operators is one 
example. The behavior of len(c) is another. If c.__len__ does not exist, 
(the programmers fault for calling len(c)), it raises one message. If 
c.__len__ does not return a non-negative int, it raises another.

 > for that matter, they're both isomorphic to closures.

Translating into Python, does this refer to the fact that bound methods 
are closures?

> In effect, your "objects" are just single-parameter functions, and
> your "messages" are the call operator.

The proposal seems to be that every object should have a 
single-parameter call method that in turn calls a preferred, default 
single-parameter named method.

For lists: def __call__(self, ob): self.append(ob)
For ints: def __call__(self, other): return self.__add__(other)

That seems useless as a general pattern.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Python-ideas] Message passing syntax for objects Terry Reedy <tjreedy@udel.edu> - 2013-03-19 16:09 -0400

csiph-web