[Python-ideas] a new lambda syntax
Stephen J. Turnbull
stephen at xemacs.org
Tue Oct 20 20:23:57 CEST 2009
Masklinn writes:
> On 20 Oct 2009, at 07:37 , Stephen J. Turnbull wrote:
> > That doesn't look like what "anonymous block" means to me. It looks
> > like a lambda.
> >
> An anonymous block and a lambda are the exact same thing.
<WHINE>
Why use different names for them, then? At least when discussing
Python which calls the concept "lambda"?
</WHINE>
> > The difference is that an block resolves all its non-argument
> > references in the calling context
> Are you talking about forming closures here?
No, I'm talking about the exact opposite, I think. Let's forget Ruby,
since we're talking about anonymous functions after all, and what I
"know" about Ruby is all hearsay (and evidently not correctly
understood at that). In Lisp, you can do something like this:
(defvar i)
(defvar f (lambda () (print i)))
(do ((i 10 (- i 1)))
((< i 1))
(funcall f))
outputting 10 9 8 7 6 5 4 3 2 1 and returning nil. Ie, it was my
understanding of "block" that free variables in the block have what in
Lisp is called "dynamic scope".
> > So a block seems to be a conventional way of currying a more
> > general function to the context of a specific suite.
That was a brain bubble, sorry.
More information about the Python-ideas
mailing list