Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'expressions': 0.07; 'restriction': 0.09; 'subject: [': 0.09; 'sure,': 0.09; 'val': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'lambda': 0.16; 'lower,': 0.16; 'subject:expressions': 0.16; 'subject:unicode': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'actual': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'being': 0.38; 'implement': 0.38; 'expression': 0.60; 'here': 0.66; 'mar': 0.68; 'collection.': 0.84; 'to:none': 0.92 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:cc :content-type; bh=jjMBUTHABUPrvqKAiPBxgU7Bqfg0bLy1v5lKMwAdpQg=; b=kj30S2Ce1l8s3vP1aheFBzP+ZiNABaVzZ30WsYdG5aOBkJIT9O7szWKqo65wzUaN2p MLxzdvS13cn/CRoOvIJO1Iw7q59tAtUe8/F7hbvi0r6O+MgBpb4eHDjAJOYEdfH0i/RQ AEWkJAoIjqkBU49syg2htmrdKLMkJMIOxJGV6N5uv8fUGDCmXWJ9hhZzvr66wH0vQ61d ZKqGvluDFRtMbsvTNi9QBYrP2j6909ESKsEwJzXql4Ku9Zn4DxwkmCTRlrAIm2ZiAgdk NRVuLTzeaGUHWzBhDQ3d16LNBbLh5wqF4sh8V+iHmLOrpmpGfj2SZdour7WZH6tRK43+ HT2Q== MIME-Version: 1.0 X-Received: by 10.68.197.36 with SMTP id ir4mr88143469pbc.46.1395872689390; Wed, 26 Mar 2014 15:24:49 -0700 (PDT) In-Reply-To: <9ad6730a-f2d9-42fe-a822-88db2916972b@googlegroups.com> References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <281c8ce1-4f03-4e93-b5cd-d45b85e89e7e@googlegroups.com> <53314FC1.2010603@rece.vub.ac.be> <5331652c$0$29994$c3e8da3$5496439d@news.astraweb.com> <53319e60$0$29994$c3e8da3$5496439d@news.astraweb.com> <53321b7e$0$29994$c3e8da3$5496439d@news.astraweb.com> <5332fae0$0$29994$c3e8da3$5496439d@news.astraweb.com> <9ad6730a-f2d9-42fe-a822-88db2916972b@googlegroups.com> Date: Thu, 27 Mar 2014 09:24:49 +1100 Subject: Re: Delayed evaluation of expressions [was Re: Time we switched to unicode?] From: Chris Angelico Cc: "python-list@python.org" 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395872698 news.xs4all.nl 2847 [2001:888:2000:d::a6]:34041 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69150 On Thu, Mar 27, 2014 at 4:32 AM, Rustom Mody wrote: > Now actual python > > def sumjensen(i_get, i_set,lower,upper,exp): > tot = 0 > i_set(lower) > while i_get() <= upper: > tot += exp_get() > i_set(i_get() + 1) > return tot > > > i=0 > a=[3,4,5] > i_get = lambda : i > def i_set(val): > global i > i = val > > exp_get = lambda : a[i_get()] > > > call as sumjensen(i_get, i_set, lower, upper, exp_get) > > [Note that because of lambda's restriction to being only an expression > I have to make it a def because of need for global] You prove here that Python has first-class expressions in the same way that 80x86 assembly language has garbage collection. Sure, you can implement it using the primitives you have, but that's not support. ChrisA