Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder3.xlned.com!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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'argument': 0.05; 'compact': 0.09; 'function,': 0.09; 'statements': 0.09; 'python': 0.11; 'def': 0.12; '"good': 0.16; 'declaration': 0.16; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iteration.': 0.16; 'lambda': 0.16; 'notation': 0.16; 'subject:Programming': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; '(but': 0.19; "python's": 0.19; 'value.': 0.19; 'case.': 0.24; 'lets': 0.24; "i've": 0.25; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; 'that.': 0.31; 'usually': 0.31; '(since': 0.31; 'another': 0.32; 'programmers': 0.33; "can't": 0.35; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'limitations': 0.36; 'doing': 0.36; 'two': 0.37; 'sometimes': 0.38; 'to:addr:python- list': 0.38; 'aside': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'middle': 0.60; 'most': 0.60; 'simple': 0.61; 'more': 0.64; 'between': 0.67; 'approaches': 0.68; 'important;': 0.84; 'optimized.': 0.84; '2013,': 0.91; 'approach.': 0.91; 'incredibly': 0.96; '2013': 0.98 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=eNJkKON3z2cG1mJyZzE1cT4+XqwZpRvS58wbJWi4rb0=; b=QriGI5JLXN51a3itIlb9AQZXS15ejRiih0bEvPVwDzSRJHuiC6UvKeB+txXKmtO2gW XGxlxdHMFXPGh+cqmd4615ccCX2QftyuWy8ODA0usiNtP2Oojwv7iAFJARn50DxWiGyw OTMbS0OIvUlyMo7psizjHUp55+ZykZGRbLZwdpaPv/jEbNJ5kp3UccmR2CHacpeRx8ss 07vM64XzK++4omrgsxTlTezB/J7P7TSXHvydPl0/gEIkEw1cKwhpL43krzsInzYG9LGU PdaF0zq0Ex3GuEMeu3o6ZXzv3cP00GyxUZVFwYxRgSWadHNFwT1r87Oazo5mqglIz2+9 xtKA== MIME-Version: 1.0 X-Received: by 10.220.43.19 with SMTP id u19mr23240474vce.3.1380561465516; Mon, 30 Sep 2013 10:17:45 -0700 (PDT) In-Reply-To: References: Date: Tue, 1 Oct 2013 03:17:45 +1000 Subject: Re: Functional Programming and python From: Chris Angelico To: python-list@python.org 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380561468 news.xs4all.nl 15876 [2001:888:2000:d::a6]:34239 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55091 On Tue, Oct 1, 2013 at 3:04 AM, Franck Ditter wrote: > 1. Tail recursion is not optimized. We are in 2013, why ? This is known technology (since 1960). > And don't answer with "good programmers don't use recursion", this is bullshit. I've yet to see any value in having the compiler/interpreter optimize tail recursion that can't be achieved just as well, and usually more clearly, with simple iteration. Recursion's important; tail recursion's important; tail recursion optimization isn't. (But I do sometimes yearn for a goto.) > 2. Lambda-expression body is limited to one expression. Why ? > Why the hell those limitations ? In this aspect, Javascript has a cooler approach. Since you can just use def in the middle of another function, the difference between def and lambda isn't all that huge. Yes, def isn't an expression - but Python's lambda gives an incredibly compact notation for the common case. Compare these two snippets: # Python odd_numbers = filter(lambda x: x%2, numbers) //Pike odd_numbers = filter(numbers, lambda(int x) {return x%2;}) Aside from the type declaration and the argument order, these two snippets are doing exactly the same thing in exactly the same way. Python's version is way more compact. Pike's version lets you put multiple statements into the expression... but most of the time you don't need that. Both approaches have their value. ChrisA