Re: Common LISP-style closures with Python

2012-02-10 Thread 88888 Dihedral
在 2012年2月4日星期六UTC+8上午8时27分56秒,Antti J Ylikoski写道: > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: > > - > > # Ma

Re: Common LISP-style closures with Python

2012-02-09 Thread John Nagle
On 2/3/2012 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: Most dynamic languages have closures. Even Perl and Javascript have closures

Re: Common LISP-style closures with Python

2012-02-06 Thread Rick Johnson
On Feb 3, 6:27 pm, Antti J Ylikoski wrote: > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python.  It > is done as follows: > [...] do my eyes not see nor my ears not hear? a thread about common

Re: Common LISP-style closures with Python

2012-02-05 Thread Antti J Ylikoski
On 5.2.2012 22:58, Ian Kelly wrote: On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: I'm not sure how naughty this is, but the same thing can be done without using nonlocal by storing the local state as an attribute of the enclosed function object: ... Yes, I do know that, but then it

Re: Common LISP-style closures with Python

2012-02-05 Thread Ian Kelly
On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: >> I'm not sure how naughty this is, but the same thing can be done without >> using >> nonlocal by storing the local state as an attribute of the enclosed >> function >> object: >> >> ... > > Yes, I do know that, but then it would not be a c

Re: Common LISP-style closures with Python

2012-02-05 Thread Alan Ristow
On 02/05/2012 05:19 AM, Antti J Ylikoski wrote: Yes, I do know that, but then it would not be a closure :-) Forgive me if this is terribly naive, but what is the advantage of using a closure as opposed to, say, some other function that returns the same value in the same context, but

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 5.2.2012 3:31, John O'Hagan wrote: On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1(): n = 0 def f2(): nonlocal n n += 1 return n return

Re: Common LISP-style closures with Python

2012-02-04 Thread John O'Hagan
On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > [...] > > i.

Re: Common LISP-style closures with Python

2012-02-04 Thread Devin Jeanpierre
On Sat, Feb 4, 2012 at 5:58 AM, Arnaud Delobelle wrote: > I think what Chris asking is: what is the feature of Common-Lisp > closures that Python closures share but other languages don't? > > I think what he is implying is that there is no such feature.  Python > closures are no more "Common-Lisp-

Re: Common LISP-style closures with Python

2012-02-04 Thread Tomasz Rola
On Sat, 4 Feb 2012, Antti J Ylikoski wrote: > On 4.2.2012 12:58, Arnaud Delobelle wrote: > > On 4 February 2012 10:14, Antti J Ylikoski wrote: > > > On 4.2.2012 4:47, Chris Rebert wrote: > > > > Out of curiosity, what would be non-Common-Lisp-style closures? > > > > > > > > Cheers, > > > > Chris

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 12:58, Arnaud Delobelle wrote: On 4 February 2012 10:14, Antti J Ylikoski wrote: On 4.2.2012 4:47, Chris Rebert wrote: Out of curiosity, what would be non-Common-Lisp-style closures? Cheers, Chris I understand that a "closure" is something which is typical of functional program

Re: Common LISP-style closures with Python

2012-02-04 Thread Arnaud Delobelle
On 4 February 2012 10:14, Antti J Ylikoski wrote: > On 4.2.2012 4:47, Chris Rebert wrote: >> Out of curiosity, what would be non-Common-Lisp-style closures? >> >> Cheers, >> Chris > > > I understand that a "closure" is something which is typical of functional > programming languages.  -- Scheme-st

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 12:14, Antti J Ylikoski wrote: On 4.2.2012 4:47, Chris Rebert wrote: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as

Re: Common LISP-style closures with Python

2012-02-04 Thread Antti J Ylikoski
On 4.2.2012 4:47, Chris Rebert wrote: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows

Re: Common LISP-style closures with Python

2012-02-03 Thread Chris Rebert
On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python.  It > is done as follows: > > - > > #

Common LISP-style closures with Python

2012-02-03 Thread Antti J Ylikoski
In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: - # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1