Re: Lisp-likeness

2005-03-16 Thread Ville Vainio
> "Michele" == michele simionato <[EMAIL PROTECTED]> writes: Michele> But then why he agreed to have the loop variable Michele> disappear outside a generator comprehension? I think Michele> there is something more than a backward compatibility Michele> concern. With normal fo

Re: Lisp-likeness

2005-03-16 Thread michele . simionato
But then why he agreed to have the loop variable disappear outside a generator comprehension? I think there is something more than a backward compatibility concern. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp-likeness

2005-03-16 Thread Greg Ewing
Michele Simionato wrote: However this approach has a drawback (which is not there in Scheme, since Scheme has set!): if a new scope was created at each iteration (which is what the function call is doing) we could not reassign variables (i.e. they would become names locals to the "for" scope, touch

Re: Lisp-likeness

2005-03-16 Thread Michele Simionato
> I'm surprised that Michele >hasn't yet referenced the thread where we exposed the gory details, as >was his custom for a while :-) >Message-ID: <[EMAIL PROTECTED]>, for >this particular >aspect, in case anyone gives a monkey's left testicle. I had forgot the title of that thread and also I wante

Re: Lisp-likeness

2005-03-16 Thread Jacek Generowicz
"Carl Banks" <[EMAIL PROTECTED]> writes: > Michele Simionato wrote: > > Carl Banks: > > > If Python did it the way Scheme did, this would be pretty useless. > > > > But notice that Scheme has no problems whatsoever: > > > > (define (toplevel) > > (define a 1) > > (define (f) > > (display a

Re: Lisp-likeness

2005-03-16 Thread Carl Banks
Marcin 'Qrczak' Kowalczyk wrote: > The issue is about the semantics of loops: whether they introduce > a new variable for each iteration, or change the value of a single > variable. Yes, I see what you are saying now. Good point. -- CARL BANKS -- http://mail.python.org/mailman/listinfo/pyth

Re: Lisp-likeness

2005-03-16 Thread Carl Banks
Michele Simionato wrote: > Carl Banks: > > If Python did it the way Scheme did, this would be pretty useless. > > But notice that Scheme has no problems whatsoever: > > (define (toplevel) > (define a 1) > (define (f) > (display a)) > (set! a 2) > (f)) > > (toplevel) > > prints 2 the sa

Re: Lisp-likeness

2005-03-16 Thread Marcin 'Qrczak' Kowalczyk
"Carl Banks" <[EMAIL PROTECTED]> writes: >> BTW, the fact that a closure refers to a variable itself rather to >> its current value can be used to check the true attitude of >> languages with respect to functional programming, by observing how >> they understand their basic loops :-) > Closing on

Re: Lisp-likeness

2005-03-16 Thread Pascal Bourguignon
[EMAIL PROTECTED] (Peter Lewerin) writes: > Fred Gilham <[EMAIL PROTECTED]> wrote > > > > And Lisp's "macro language" isn't involved at all here. > > > Also, #' is a read-macro. > > A read-macro and a macro aren't the same thing. > > > Then there's the "defun" macro . . . . > > There is IMHO

Re: Lisp-likeness

2005-03-16 Thread Michele Simionato
Carl Banks: > Python might lose when it comes to functional programming, > but it wins when it comes to nested functions like this (where a,b,c,d > are in the enclosing scope and presumably changing): > def print_variables(): >print a,b,c,d Yes, clearly if I have def toplevel(): a

Re: Lisp-likeness

2005-03-16 Thread Michele Simionato
Or, just to impress Lispers, >>> def add(x,y): ... return x + y >>> closures = [] >>> for i in range(10): ...closures.append(add.__get__(i)) ... >>> closures[5](1000) 1005 Remember, in Python do not have functions, we have descriptors! ;) Michele Simionato -- http:/

Re: Lisp-likeness

2005-03-16 Thread Fernando
On Wed, 16 Mar 2005 00:36:40 +0100, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > > >BTW, the fact that a closure refers to a variable itself rather to its >current value can be used to check the true attitude of languages with >respect to functional programming, by observing how they un

Re: Lisp-likeness

2005-03-16 Thread Peter Lewerin
Fred Gilham <[EMAIL PROTECTED]> wrote > > And Lisp's "macro language" isn't involved at all here. > Also, #' is a read-macro. A read-macro and a macro aren't the same thing. > Then there's the "defun" macro . . . . There is IMHO a difference between using a macro and using the "macro language

Re: Lisp-likeness

2005-03-15 Thread Bengt Richter
On Wed, 16 Mar 2005 00:36:40 +0100, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] (Thomas A. Russ) writes: > >>> >(defun addn (n) >>> > #'(lambda (x) >>> > (+ x n))) >>> >>> The same as >>> def addn(n): >>> def fn(x): >>> return n + x >>>

Re: Lisp-likeness

2005-03-15 Thread Carl Banks
Marcin 'Qrczak' Kowalczyk wrote: > [EMAIL PROTECTED] (Thomas A. Russ) writes: > > >> >(defun addn (n) > >> >#'(lambda (x) > >> >(+ x n))) > >> > >> The same as > >> def addn(n): > >>def fn(x): > >>return n + x > >>return fn > > > > Is this really equivalent? > > > >

Re: Lisp-likeness

2005-03-15 Thread Steven E. Harris
Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes: > BTW, the fact that a closure refers to a variable itself rather to its > current value can be used to check the true attitude of languages with > respect to functional programming, by observing how they understand > their basic loops :-) The

Re: Lisp-likeness

2005-03-15 Thread Pascal Costanza
Marcin 'Qrczak' Kowalczyk wrote: [EMAIL PROTECTED] (Thomas A. Russ) writes: (defun addn (n) #'(lambda (x) (+ x n))) The same as def addn(n): def fn(x): return n + x return fn Is this really equivalent? What happens if you call addn more than once with different paramet

Re: Lisp-likeness

2005-03-15 Thread Marcin 'Qrczak' Kowalczyk
[EMAIL PROTECTED] (Thomas A. Russ) writes: >> >(defun addn (n) >> > #'(lambda (x) >> > (+ x n))) >> >> The same as >> def addn(n): >> def fn(x): >> return n + x >> return fn > > Is this really equivalent? > > What happens if you call addn more than once with

Re: Lisp-likeness

2005-03-15 Thread Roel Schroeven
Thomas A. Russ wrote: > Fernando <[EMAIL PROTECTED]> writes: > > >>On 15 Mar 2005 00:43:49 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> >>wrote: >> >> >>>Maybe You can answer my question what this simple LISP function does ? >>> >>>(defun addn (n) >>> #'(lambda (x) >>> (+ x n))) >>

Re: Lisp-likeness

2005-03-15 Thread Marcin 'Qrczak' Kowalczyk
[EMAIL PROTECTED] (Thomas A. Russ) writes: >> >(defun addn (n) >> > #'(lambda (x) >> > (+ x n))) >> >> The same as >> def addn(n): >> def fn(x): >> return n + x >> return fn > > Is this really equivalent? > > What happens if you call addn more than once with

Re: Lisp-likeness

2005-03-15 Thread Valentino Volonghi aka Dialtone
Thomas A. Russ <[EMAIL PROTECTED]> wrote: > > >(defun addn (n) > > > #'(lambda (x) > > > (+ x n))) > > > > The same as > > def addn(n): > > def fn(x): > > return n + x > > return fn > > Is this really equivalent? yes > What happens if you call addn more than on

Re: Lisp-likeness

2005-03-15 Thread Matthew D Swank
On Tue, 15 Mar 2005 14:16:09 -0800, Thomas A. Russ wrote: > The lisp snippet creates new functions each time the addn function is > called, so one can interleave calls to the individual functions. Yes, I believe them to be equivalent. Each call to addn creates an activation record which is closed

Re: Lisp-likeness

2005-03-15 Thread Thomas A. Russ
Fernando <[EMAIL PROTECTED]> writes: > > On 15 Mar 2005 00:43:49 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> > wrote: > > >Maybe You can answer my question what this simple LISP function does ? > > > >(defun addn (n) > > #'(lambda (x) > > (+ x n))) > > The same as > def addn(n):

Re: Lisp-likeness

2005-03-15 Thread Fred Gilham
> (defun addn (n) > (lambda (x) > (+ x n))) > > And Lisp's "macro language" isn't involved at all here. (macroexpand-1 '(lambda (x) (+ x n))) => #'(LAMBDA (X) (+ X N)) Also, #' is a read-macro. Fully expanded the #'(lambda expression would be (function (lambda (x) (+ x n))

Re: Lisp-likeness

2005-03-15 Thread Fernando
On 15 Mar 2005 00:43:49 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >Maybe You can answer my question what this simple LISP function does ? > >(defun addn (n) > #'(lambda (x) > (+ x n))) The same as def addn(n): def fn(x): return n + x ret

Re: Lisp-likeness

2005-03-15 Thread Michael Hoffman
Peter Lewerin wrote: "Kay Schluehr" <[EMAIL PROTECTED]> wrote > Maybe You can answer my question what this simple LISP function does ? It obviously returns a function adding n to the function's parameter, n being bound into the functions's closure during the call to ADDN. It's simple and straightf

Re: Lisp-likeness

2005-03-15 Thread Peter Lewerin
"Kay Schluehr" <[EMAIL PROTECTED]> wrote > Maybe You can answer my question what this simple LISP function does ? It obviously returns a function adding n to the function's parameter, n being bound into the functions's closure during the call to ADDN. It's simple and straightforward. > This is

Re: Lisp-likeness

2005-03-15 Thread Albert Reiner
[EMAIL PROTECTED], Tue, 15 Mar 2005 13:10:52 +0100]: > It's indeed correct CL syntax, but I don't see much macro usage in there. defun? Albert. -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp-likeness

2005-03-15 Thread ole . rohne
Kay> Maybe You can answer my question what this simple LISP function does ? Kay> (defun addn (n) Kay> #'(lambda (x) Kay> (+ x n))) Is that a real question or are you making a rhetorical point here? Kay> This is correct LISP-syntax if You bear in mind LISPs powerwull macro Kay> langu

Lisp-likeness

2005-03-15 Thread Kay Schluehr
Maybe You can answer my question what this simple LISP function does ? (defun addn (n) #'(lambda (x) (+ x n))) This is correct LISP-syntax if You bear in mind LISPs powerwull macro language... I think Guido and python-dev are very carefull in adding new power to Python. T