Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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; 'python.': 0.02; 'operator': 0.03; 'argument': 0.05; 'widely': 0.05; 'args': 0.07; 'compiler': 0.07; 'context': 0.07; 'explicit': 0.07; 'expressions': 0.07; 'suppose': 0.07; 'adopted': 0.09; 'builtin': 0.09; 'executed': 0.09; 'function,': 0.09; 'interpreted': 0.09; 'present,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'statements': 0.09; 'subject: [': 0.09; 'works.': 0.09; 'python': 0.11; 'jan': 0.12; 'wrote': 0.14; 'mostly': 0.14; 'any.': 0.16; 'assignments': 0.16; 'convey': 0.16; 'conveys': 0.16; 'excludes': 0.16; 'expressions,': 0.16; 'lisp,': 0.16; 'loops': 0.16; 'macros.': 0.16; 'operation.': 0.16; 'oppose': 0.16; 'pairs': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'subject:expressions': 0.16; 'subject:unicode': 0.16; 'syntactic': 0.16; 'do,': 0.16; '(not': 0.18; 'code.': 0.18; 'all,': 0.19; 'mechanism': 0.19; "python's": 0.19; 'later': 0.20; 'meant': 0.20; '(the': 0.22; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'integer': 0.24; 'lets': 0.24; 'of.': 0.24; 'why.': 0.24; 'initial': 0.24; 'this:': 0.26; 'tracker': 0.26; 'second': 0.26; 'pass': 0.26; 'post': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'feature': 0.29; 'possibility': 0.29; "doesn't": 0.30; 'mode': 0.30; 'strongly': 0.30; 'included': 0.31; 'code': 0.31; 'url:wiki': 0.31; 'usually': 0.31; 'about.': 0.31; 'apparently': 0.31; 'boundary': 0.31; 'breaking': 0.31; 'concern': 0.31; 'doc': 0.31; 'implicit': 0.31; 'implied': 0.31; 'name;': 0.31; 'question:': 0.31; 'responded': 0.31; 'url:wikipedia': 0.31; 'supposed': 0.32; 'themselves': 0.32; 'text': 0.33; 'reader': 0.33; 'third': 0.33; 'comment': 0.34; 'maybe': 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'agree': 0.35; 'knows': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'are,': 0.36; 'marks': 0.36; 'opposed': 0.36; 'url:org': 0.36; 'should': 0.36; 'changing': 0.37; 'two': 0.37; 'step': 0.37; 'depends': 0.38; 'form,': 0.38; 'generic': 0.38; 'you.': 0.62; 'name': 0.63; 'real': 0.63; 'such': 0.63; 'sum': 0.64; 'more': 0.64; 'different': 0.65; 'readers': 0.68; 'default': 0.69; 'obvious': 0.74; 'special': 0.74; 'other.': 0.75; 'article': 0.77; '100': 0.79; '"can\'t"': 0.84; "'for'": 0.84; '(let': 0.84; 'article,': 0.84; 'confusing': 0.84; 'confusion.': 0.84; 'encounters': 0.84; 'everything,': 0.84; 'fourth': 0.84; 'received:fios.verizon.net': 0.84; 'do:': 0.91; 'whereas': 0.91; 'quotation': 0.93; 'treatment': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?] Date: Wed, 26 Mar 2014 20:44:17 -0400 References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <281c8ce1-4f03-4e93-b5cd-d45b85e89e7e@googlegroups.com> <53314FC1.2010603@rece.vub.ac.be> <5331652c$0$29994$c3e8da3$5496439d@news.astraweb.com> <53319e60$0$29994$c3e8da3$5496439d@news.astraweb.com> <53321b7e$0$29994$c3e8da3$5496439d@news.astraweb.com> <5332fae0$0$29994$c3e8da3$5496439d@news.astraweb.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-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <5332fae0$0$29994$c3e8da3$5496439d@news.astraweb.com> 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: 119 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395881083 news.xs4all.nl 2942 [2001:888:2000:d::a6]:41461 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69157 I agree that we have not been understanding each other. From you original post that I responded to: >>>>> The thing is, we can't just create a =E2=88=91 function, because it= doesn't >>>>> work the way the summation operator works. The problem is that we >>>>> would want syntactic support, so we could write something like this= : >>>>> p =3D 2 >>>>> =E2=88=91(n, 1, 10, n**p) The initial misunderstanding is that I interpreted 'something like this' = more loosely than you meant it. So I wrote something that was 'something = like the above' to me but not to you. I interpreted 'something like'=20 semantically* whereas you apparently meant is syntactically. I added the = one or the other little marks needed to make the above work in python as = it is whereas your 'something like' excludes such marks or any other=20 current possibility I can think of. So I actually agree that "can't" is=20 correct in relation to what you meant, as opposed to what I understood. Changing "can't" to "can" would requires a major change to Python. That=20 change is one I would strongly oppose and I will try to explain more=20 clearly why. [*When I qualify doc suggestions on the tracker with 'something like',=20 as I usually do, I mean something that conveys the same meaning. So I=20 edited your call text to convey the intended meaning in Python.] Lets start with things we should agree on. The first two are mostly not = specific to Python. 1. When a compiler encounters an expression in code, there are at least=20 three things it can do: 1a. compile it so that it is immediately executed when encountered at=20 runtime (let this be the default); 1b. compile it so that it is somehow saved for execution later or=20 elsewhere (the alternative of concern here); 1c. compile it for a different alternative, such as turning an implied=20 'get' operation into a 'set' operation. 2. A code writer who wants an alternative treatment for a particular=20 must somehow delineate the expresion with boundary markers that, in=20 context at least, also indicate the alternative treatment. There are,=20 broadly, two possibilities: 2a. Use a generic quotation mechanism that can be applied to any=20 expression most any place. I call this explicit quoting. 2b. Use the expression in a special form that the compiler knows about.=20 The special form must have begin-end markers of some sort. I call this=20 implicit quoting. If human readers do not know that a particular form is = a special form, they may have a problem understanding the code. Python has 2 pairs of generic explicit delimiters: open-close quote=20 marks and lambda-, where is ',', ')',=20 , or maybe something else. If these are not present, the=20 default immediate execution mode is used for expressions in function=20 calls that are not themselves marked for alternative treatment. Python's special forms are statements. Each has its own pair of=20 delimiters. Assignments use and '=3D'. 'For' loops use = 'for' and 'in'. Other statements use 'as' and usually . Statements and functions call are syntactically very distinct, so there=20 is little possibility of confusion. I consider this a major feature of=20 python and I would oppose breaking it. Lisp, for instance, uses s-expressions for everything, including what=20 would either function calls or statements in Python. Special functions=20 implicitly quote some argument expressions, but not necessarily all,=20 while normal functions do not quote any. The only way to know is to=20 know, and I found it confusing and difficult to remember. > Sum(i, 1, 100, V[i]) > In Algol60, this function call would: > - pass the name "i" (not a string!) as the first argument; > - pass 1 as the second argument; > - pass 100 as the third argument; > - pass the expression "V[i]" (not a string!) as the fourth argument which depends for this operation on > https://en.wikipedia.org/wiki/Jensen%27s_device I read the whole article, including the criticisms and the fact that it=20 was not widely adopted and has been more or less superceded by macros.=20 It did not answer the obvious question: suppose the call is Sum(i, l, h, = V[i]). How is the reader supposed to know that 'i' and 'V[i]' get quoted = and the other args do not? The article included real procedure Sum(k, l, u, ak) value l, u; integer k, l, u; real ak; comment k and ak are passed by name; begin real s; s :=3D 0; for k :=3D l step 1 until u do s :=3D s + ak; Sum :=3D s end; If that is supposed to be real code that can be compiled, I see no way=20 for the comment to be true. Or is the mechanism limited to builtin=20 functions? --=20 Terry Jan Reedy