Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'patterns': 0.04; 'mess': 0.09; 'received:internal': 0.09; 'subject:while': 0.09; "wouldn't": 0.14; 'abusing': 0.16; 'arbitrarily': 0.16; 'intervening': 0.16; 'mechanism.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'overflow.': 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; 'remedied': 0.16; 'subject:recursion': 0.16; 'exception': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'programming': 0.22; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'idea': 0.28; 'point': 0.28; 'possibility': 0.29; 'reduced': 0.31; 'trace': 0.31; 'could': 0.34; 'received:66': 0.35; 'but': 0.35; "didn't": 0.36; 'possible': 0.36; 'received:10': 0.37; 'form,': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'does': 0.39; "couldn't": 0.39; 'flow': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'from:no real name:2**0': 0.61; 'entire': 0.61; 'header:Message-Id:1': 0.63; 'more': 0.64; '100%': 0.77; 'actually,': 0.84; 'around,': 0.84; 'investigated': 0.84; 'pardon': 0.84; '2013,': 0.91; 'serious': 0.97 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= YLgjPTSdwQjtb/NaBvA6zVkkIcc=; b=LDYA4SNG2Souodq5rGdHRzSw7iwfyktN Ruw5RBIYUzgNtvQ1TSSdbO0z9KXRxtHnQefuOsDFSEURmmoJNJx0pZSMnvoJXO7I Oh0WgWLYJ3ioRTCGCgLsvvdTGEyI/hMepT3nj2LSkvngyWTBND4uEX4OjEQ6vpca FYHw2WdNyr4= 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=YLgjPTSdwQjtb/NaBvA6zVkkIcc=; b=K2hzU hziuYrPhDcbXLb3YMq6yhW9QfZfNmb+2AvimKECWzDdgzq2TV7GEMma2DeysHsEy gPMVwIrAUGp1TRI73Q2+vBaXArBLHI0UlzXFoyL+E3WvUX7vhtt8AzkJjvHXwdLt +XXXfgK0DiGFJiEpErQZrkhOg5yBfUDM/YumMQ= X-Sasl-Enc: m7bSbFHpIPvJh0N3wzBXBgC3As1fDxwZaq/PwwgIWgOe 1381181238 From: random832@fastmail.us To: Antoon Pardon , 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: Mon, 07 Oct 2013 17:27:18 -0400 In-Reply-To: <524FC23C.70303@rece.vub.ac.be> References: <87had0axxy.fsf@dpt-info.u-strasbg.fr> <524FC23C.70303@rece.vub.ac.be> 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381181242 news.xs4all.nl 15863 [2001:888:2000:d::a6]:34854 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56331 On Sat, Oct 5, 2013, at 3:39, Antoon Pardon wrote: > What does this mean? > > Does it mean that a naive implementation would arbitrarily mess up > stack traces and he wasn't interested in investigating more > sophisticated implementations? > > Does it mean he just didn't like the idea a stack trace wouldn't be a > 100% represenatation of the active call history? > > Does it mean he investigated more sphisticated implementations but found > them to have serious short comings that couldn't be remedied easily? The entire point of tail call optimization requires not keeping the intervening stack frames around, in _any_ form, so as to allow arbitrarily deep recursion without ever having the possibility of a stack overflow. An implementation which reduced but did not eliminate the space used per call would not be worthwhile because it would not enable the recursive functional programming patterns that mandatory tail call optimization allows. You could require that an "optimizable tail call" be made explicit. Actually, I suspect it might be possible to do this now, by abusing exception handling as a control flow mechanism.