From: "Guido van Rossum"
Not at all. This is still wide open. I happen to like generalized thunks because they remind me of Ruby blocks. But I realize there are more ways to skin this cat. Keep it coming!
question, do you want thunks to be able to take arguments? is being able to write something like this a target?
iterate(list): (x): print x
Since we already have a for loop, I'm not sure what the use case would be, but it might be nice, yes. Feel free to call YAGNI on it until a better use case is found. But I imagine it would be easy enough to add on later in the design -- thunks can have free variables anyway, so providing a way to bind some of those ahead of time (and designate them as bindable) should be easy.
Go for it, write a PEP. Seriously: if redundance is not an issue for you, then is just a matter of taste (and I don't want to argue about that) and readability/transparence of what some code do (maybe someone else will argue about that). Some final remarks from my part: - With nested scope cells any kind of scoping can be achieved, so that's not a problem up to speed-wise unbalance with normal inline suites. - Non-local 'return' and 'break' can be achieved with special exceptions and uniquely identifying thunk sites, ! BUT yield inside a thunk cannot be implemented in Jython - I think that there should be a *distinguashable* syntax for introducing/using thunks with inline-suite scoping vs. 'class'-like scoping. I'm very very very uncomfortable with the idea of variable-geometry scoping, that means that I would have to go read some hairy code defining 'foo' in order to know: def f(): x=3 foo: x=2 whether the second x= is modifying the local x to f, or is just local to foo suite. - for completeness you may want to add a keyword to directly return something from a thunk to its caller, instead of non-locally return with 'return' from thunk site: def f(lst): iterate(lst): (x): if pred(x): return x # non-local return out of f def change(lst): substitute(lst): (x): value 2*x # return value to thunk caller L=[1,2,3] change(L) L is now [2,4,6]