Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'programmer': 0.03; 'syntax': 0.04; 'assignment': 0.07; 'compiler': 0.07; 'received:internal': 0.09; 'semantic': 0.09; 'subject:while': 0.09; 'python': 0.11; 'assume': 0.14; '(other': 0.16; 'family,': 0.16; 'iteration': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'reedy': 0.16; 'subject:recursion': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "python's": 0.19; 'replacing': 0.19; 'visible': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'that.': 0.31; '(since': 0.31; 'assumes': 0.31; 'implied': 0.31; 'operators': 0.31; 'open': 0.33; 'received:66': 0.35; 'late': 0.35; 'really': 0.36; 'should': 0.36; 'received:10': 0.37; 'expressed': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'conversion': 0.61; 'header:Message-Id:1': 0.63; 'field': 0.63; 'side': 0.67; 'determine': 0.67; 'iterative': 0.84; 'recursive.': 0.84; '2013,': 0.91; 'apparent': 0.91; 'effects.': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:subject:date:in-reply-to:references; s=mesmtp; bh= arGeP9Zn7wCwqXEln/XlfUWhk8s=; b=JlIpl5ASMZDuqo3Z+5KkFWyqs1fELP8z g8+Uf2c+UXDcTZ9Nypmbq9FkTum+3fPPu1+h+img2sceMATWfes/l+IhnnSnEECT cNF5NYNOfmyQlenz0IZe86ACeWPVrmk2MWMd3bdApHky2KeFXkgT4Qt9qh+rMWeG pHTrnTzZ4Wk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=smtpout; bh=arGeP9Zn7wCwqXEln/XlfUWhk8s=; b=EKv5n D1JlcTvzhEsBO8G4NSG8Ju7tyjoqc75xpJ1JcbzqUenLzXk6mSsAAHjxgkhYd2Gb yHfuyZ7z4LyXCPiCOq/X1rAZ8hUmYrDS/NM44PFZyeHn87NlWioV5OfSg1dPVhre B3eGkR3VLzIeXiIgYRVsCUllX7fGXDZmEVEHVM= X-Sasl-Enc: 0ZZ+zu3nEQi32nYpuk5Q99A7OoKlvvSeEfddIDjTJdID 1380809365 From: random832@fastmail.us To: Terry Reedy , python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-ce174988 Subject: Re: Tail recursion to while iteration in 2 easy steps Date: Thu, 03 Oct 2013 10:09:25 -0400 In-Reply-To: References: <1380717085.6985.29063445.6AD889D5@webmail.messagingengine.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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380809370 news.xs4all.nl 16005 [2001:888:2000:d::a6]:51282 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55411 On Wed, Oct 2, 2013, at 17:33, Terry Reedy wrote: > 5. Conversion of apparent recursion to iteration assumes that the > function really is intended to be recursive. This assumption is the > basis for replacing the recursive call with assignment and an implied > internal goto. The programmer can determine that this semantic change is > correct; the compiler should not assume that. (Because of Python's late > name-binding semantics, recursive *intent* is better expressed in Python > with iterative syntax than function call syntax. ) Speaking of assumptions, I would almost say that we should make the assumption that operators (other than the __i family, and setitem/setattr/etc) are not intended to have visible side effects. This would open a _huge_ field of potential optimizations - including that this would no longer be a semantic change (since relying on one of the operators being allowed to change the binding of fact would no longer be guaranteed).