Path: csiph.com!usenet.pasdenom.info!gegeweb.org!aioe.org!news.stack.nl!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.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'rewrite': 0.09; 'subject:while': 0.09; 'python': 0.11; 'fine.': 0.16; 'iteration': 0.16; 'loops': 0.16; 'mess,': 0.16; 'operator.': 0.16; 'subject:recursion': 0.16; 'ternary': 0.16; 'to:name:python list': 0.16; 'language': 0.16; 'programming': 0.22; 'saying': 0.22; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'message- id:@mail.gmail.com': 0.30; 'ones.': 0.31; 'styles': 0.31; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python- list': 0.38; 'rather': 0.38; 'does': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'easy': 0.60; 'is.': 0.60; 'total': 0.65; 'here': 0.66; 'design.': 0.68; 'overall': 0.69; 'secret': 0.74; 'steps.': 0.91; 'washington': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BXQpJv7mIM6UXD1SsVGPGkW0p9oQ9P7BnydhOZLAldU=; b=UQspxDUo+Pj4Z12hOWKxLu1jdjgWqUoh+th5SKVbsH+jVHABmvuT7MYb5KyxUMgddo LhC2ZtTVMYrzmNiFALFtxpBfwtLbyC4TRatJCLKLqo1Rz/4ZUwsCd0i7JtTddCpbdOUI SOS0LorkfxHNeZIr/adOSAysjAT/D0F/w1jxZ1/Sc+LcPyUX0nqDLmzR0b9VwN0BVDAQ AtDZV2JErOAl9PMp8ho7ESU5aw69D0c9OkPOXViNcrvm5dYLd9tQ/iEsjW5Ez7y2S0sR BOMtQEocNpuUJBlXrqAEd+r75+WIldYFGCulFXd1jm9IHkcv0FymYYLKoQ4vEsyY0RN1 xjGw== MIME-Version: 1.0 X-Received: by 10.194.240.197 with SMTP id wc5mr4258738wjc.23.1380749980103; Wed, 02 Oct 2013 14:39:40 -0700 (PDT) In-Reply-To: <1380717085.6985.29063445.6AD889D5@webmail.messagingengine.com> References: <1380717085.6985.29063445.6AD889D5@webmail.messagingengine.com> Date: Wed, 2 Oct 2013 14:39:40 -0700 Subject: Re: Tail recursion to while iteration in 2 easy steps From: Mark Janssen To: Python List Content-Type: text/plain; charset=ISO-8859-1 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380749987 news.xs4all.nl 15931 [2001:888:2000:d::a6]:39723 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55383 >> Part of the reason that Python does not do tail call optimization is >> that turning tail recursion into while iteration is almost trivial, once >> you know the secret of the two easy steps. Here it is. > > That should be a reason it _does_ do it - saying people should rewrite > their functions with loops means declaring that Python is not really a > multi-paradigm programming language but rather rejects functional > programming styles in favor of imperative ones. Yes, but that's fine. A PL language that includes every programming paradigm would be a total mess, if even possible. Python has functional programming where it does not conflict with its overall design. The only place I find that this is not the case is with lambda, but that is now adequately fixed with the addition of the ternary operator. -- MarkJ Tacoma, Washington