X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 195.154.70.45 Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'operator': 0.03; 'syntax': 0.04; 'interpreter': 0.05; 'element': 0.07; 'nested': 0.07; 'operator,': 0.09; 'parsed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'ron': 0.09; 'strings.': 0.09; 'uses.': 0.09; 'python': 0.11; "wouldn't": 0.14; '"n"': 0.16; 'adam': 0.16; 'dots': 0.16; 'once.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scope.': 0.16; 'subject:operators': 0.16; 'subtype': 0.16; 'syntactic': 0.16; 'tuple': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'implementing': 0.19; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'fairly': 0.24; 'cheers,': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; "i'm": 0.30; 'operators': 0.31; 'becomes': 0.33; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'done': 0.36; 'subject:?': 0.36; 'similar': 0.36; 'error.': 0.37; 'wrong': 0.37; 'implement': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'most': 0.60; 'course': 0.61; 'name': 0.63; 'skip:n 10': 0.64; 'charset:windows-1252': 0.65; 'effectively': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'special': 0.74; 'reply-to:addr:gmail.com': 0.80; '2015': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ron Adam Subject: Re: Rule of order for dot operators? Date: Tue, 19 May 2015 14:02:56 -0400 References: <55579886.3010001@cdreimer.com> Reply-To: ron3200@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: ip98-170-222-96.pn.at.cox.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432058593 news.xs4all.nl 2942 [2001:888:2000:d::a6]:39803 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90884 On 05/19/2015 02:25 AM, Chris Angelico wrote: > On Tue, May 19, 2015 at 12:43 PM, Ron Adam wrote: >> >Having just implementing something similar for nested scopes, it turns out >> >it can't be operators because if it was, then the names y and z would be >> >resolved in the wrong scope. >> > >> > y = "m" >> > z = "n" >> > a = x . y . z >> > >> >Which of course wouldn't do what we want. >> > >> > a = x . "m" . "n" >> > >> >And most likely this would give an error. > If you want to implement the dot as an operator, you could do it by > having a special syntactic element called an "atom", which is used for > these kinds of identifier-like tokens. The dot operator could then > take an object and an atom, and effectively return getattr(obj, > stringify(atom)). I'm fairly sure this would result in the same syntax > as Python uses. I think it's better not to. What practical things can be done if the dot was an operator and names after dots where parsed as atoms? What I did was parse a name to a subtype of tuple with elements of strings. [return name.with.dots] becomes this in memory after parsing. [keyword_object name_object] Using dots as operators would make that... [keyword_object name_object dot_object atom_object dot_object atom_object] This would require the interpreter to do in steps what a single function call can do all at once. Cheers, Ron