Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'assignment': 0.07; 'compiler': 0.07; 'parser': 0.07; 'transform': 0.07; 'lost.': 0.09; 'def': 0.12; 'reedy': 0.16; 'subject:def': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'replacing': 0.19; 'feb': 0.22; 'issue.': 0.22; 'byte': 0.24; 'recognize': 0.24; 'purposes': 0.26; 'header :In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'code': 0.31; 'implicit': 0.31; 'could': 0.34; "can't": 0.35; 'received:google.com': 0.35; 'easily': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'simple': 0.61; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'lack': 0.78; '2015': 0.84; 'subject:Alternative': 0.84; 'generation.': 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=XCvIjgZFTvL/s6ikKquCcgHlXmkdxNUmlwG2VUGQO3Q=; b=JnFl0v24XECZK6bB1J3ug4fitBXyxMBC0AgsEFgdhetDC65HKJaYUmPE+4xueI8Eue Yg7gipeRnHo9RZXLrdE99wPU0snSXXHfiC9FYowtIePA0Php257D01YI+bkwh5ujV/jX jwxZkaAlYB9yMyD0Ex8IGxcxcqQEqoXfDCovVUjMKM3ShpnHMrlcdLAOI36zOqPx2Lw3 dLiTJoaKXEJ1gXblDtdb2v0XwAQSCBk2uquMkOTbc923DlsLI06mAzYRP9+xLT1ALub1 Gwjta9QmNrW2kUGPHlEx4TPRlL4e6Yl+kWOziVpSG1i3HzWsMRX7dQgVa+PVkWr1Zo44 xu5A== X-Received: by 10.66.141.71 with SMTP id rm7mr2751619pab.114.1423709881155; Wed, 11 Feb 2015 18:58:01 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54C3EAD1.2010501@stoneleaf.us> <54db5356$0$3915$e4fe514c@dreader34.news.xs4all.nl> From: Ian Kelly Date: Wed, 11 Feb 2015 19:57:20 -0700 Subject: Re: Alternative to multi-line lambdas: Assign-anywhere def statements To: Python Content-Type: text/plain; charset=UTF-8 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423709889 news.xs4all.nl 2868 [2001:888:2000:d::a6]:60279 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85563 On Wed, Feb 11, 2015 at 7:06 PM, Terry Reedy wrote: >> I can't see why the parser would understand more easily >> >> def f(x): >> return x**2 >> than >> >> f = x-> >> return x**2 > > > The parser parses both equally well. That is not the issue. The compiler could at some point recognize that the function is being assigned to a simple name and transform the assignment into a def for purposes of byte code generation. It could also do the same with lambda, although it currently doesn't. The reason I don't like this replacing def isn't because the name is necessarily lost. It's because the lack of the well-defined def statement encourages more complex usages like functions['f'] = x -> x**2 where such implicit transformations won't work.