Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'omit': 0.07; 'compiler.': 0.09; 'bug': 0.10; 'python': 0.10; 'explicitly': 0.15; 'result.': 0.15; 'confusion': 0.16; 'entirely.': 0.16; 'foo()': 0.16; 'programmer,': 0.16; 'wrote:': 0.16; 'pointed': 0.18; "shouldn't": 0.18; 'programmer': 0.18; '>>>': 0.20; '2015': 0.20; 'controlling': 0.22; 'explicit': 0.22; 'am,': 0.23; 'header:In- Reply-To:1': 0.24; 'mon,': 0.24; "doesn't": 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; '13,': 0.29; 'tail': 0.29; "they'll": 0.29; 'subject:/': 0.30; 'statement': 0.32; 'point': 0.33; 'controls': 0.33; 'changing': 0.34; 'definition': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'instead': 0.36; 'keyword': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'responsible': 0.37; "won't": 0.38; 'mean': 0.38; 'means': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'forget': 0.60; 'behavior': 0.61; 'today.': 0.67; 'jul': 0.72; 'led': 0.72; 'miss': 0.77; 'viewed': 0.79; 'difference.': 0.84; 'to:name:python': 0.84; 'mistakenly': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=95hByLWtZ+Mya3d/0LqBydvdx1PxKqfErL8nOrsZjkg=; b=W5rYxVmeqvVdw4w+3V3UtuW+MTfZ9UJ0hpfIsH1uFAP8k3CnWW6pilV6nCGEOjWx8w icFv8w8W5X5R6fzx3jD68U0oofoSjmJi6TGFIRxRSkUtNoIEK1Tlg68cYUExkqnp7iIt ovlTt0BlqN2seZuVANM64fEwxlj0ZglNTgFMd4pAKJhvzKjqUKraZNgqEUxBTThqp3ja j4C0xfEPEq742qQBg9fMDQX+ManpCR0veeDdElJ2tz6CtjCbD8THt/LsYrft9MQ22rpd Dqdmom7aIChDr245+5WFbnWJrnw2BkI4HmBIV5dXW9PXKup+pWdDJIbxaKWHZ8cliraG hCcA== X-Received: by 10.13.251.199 with SMTP id l190mr45324027ywf.148.1436879758584; Tue, 14 Jul 2015 06:15:58 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87pp3vm93f.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> From: Ian Kelly Date: Tue, 14 Jul 2015 07:15:19 -0600 Subject: Re: Possibly Pythonic Tail Call Optimization (TCO/TRE) To: Python Content-Type: text/plain; charset=UTF-8 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436879766 news.xs4all.nl 2878 [2001:888:2000:d::a6]:45629 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93808 On Tue, Jul 14, 2015 at 2:33 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Mon, Jul 13, 2015 at 11:57 PM, Marko Rauhamaa wrote: >>> How about "return"? >> >> I think you miss my point entirely. "return" doesn't mean tail-call >> optimize; > > Why not? > >> it just means to return the result. > > Same difference. > >> This is what led to the confusion responsible for the bug that Chris >> pointed out in the first place. With a keyword that explicitly means >> "perform tail-call optimization *and* return", > > That could well be the explicit definition of the "return" statement in > Python without changing the behavior of any working Python program > today. To the compiler. It won't be viewed that way be the programmer, however. So they'll forget that the "return" is necessary to the optimization and just write quicksort() instead of return quicksort(). >> the association of the keyword with the optimization is much clearer, >> and the programmer is much less likely to mistakenly omit it. > > The programmer shouldn't be controlling tail call optimizations. The programmer controls it regardless. return foo() # TCO result = foo() # No TCO return result # No TCO