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: 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 Subject: Re: [Python-ideas] Message passing syntax for objects Date: Tue, 19 Mar 2013 16:09:44 -0400 References: <5146B848.3040509@pearwood.info> <1363643500.25746.YahooMailNeo@web184701.mail.ne1.yahoo.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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=E2=80=94and, Since the isomorphism is so obvious, I somehow missed that Kay actually=20 thought that they were different. I suppose one could have different=20 (but isomorphic) mental image models. For me, the problem with message passing, as usually though of, or=20 method calls in their usual syntax, is the breaking of symmetries such=20 as the commutivity of number addition. I think of 'a + b' as a message=20 to the interpreter, as supervisor of Python objects, to add a and b=20 together and give me the result. It turns out that a Python interpreter=20 does that by calling *either* a.__add__(b) or b.__add__(a) or possibly bo= th. The advantage of passing messages through a supervisor is that it can=20 'supervise' the process. The behavior with binary operators is one=20 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=20 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=20 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=20 single-parameter call method that in turn calls a preferred, default=20 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. --=20 Terry Jan Reedy