> "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
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
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
> 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
"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
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
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
"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
[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
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
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:/
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
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
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
>>>
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?
> >
> >
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
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
[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
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)))
>>
[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
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
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
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):
> (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))
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
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
"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
[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
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
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
30 matches
Mail list logo