[Python-Dev] thunks (original) (raw)
Samuele Pedroni pedronis@bluewin.ch
Mon, 3 Feb 2003 18:20:42 +0100
- Previous message: [Python-Dev] thunks
- Next message: [Python-Dev] thunks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: "Guido van Rossum" <guido@python.org>
I still don't have time to read this thread :-(, but I had a new idea that I'd like to fly here.
If we want to support thunks that blend into the scope of their environment as well as thunks that introduce a new local scope, here's one possible way to do it: Thunk blending in: [ =] : Thunk introducing a new local scope: [ =] lambda: (Never mind the ugly things I've said about lambda in the past. :-) I'm confident that the parser can distinguish these, and I'm confident that the scope blending can be implemented using nested-scope cells. Adding formal parameters to the second case would go like this: [ =] lambda : One concern I have in both cases: I think there are use cases for wanting more than one block. Glyph's example wants to define various callbacks for a remote call, and this would need multiple blocks. I think the syntax for this would have to use some kind of keyword-based continuation, e.g. [ =] lambda: and lambda: ... Disclaimer: this is a half-baked idea.
Is lambda for generalizing 'class'?? It is worth to rember that 'class' has different scoping rules than def!
def c(): ... x = 1 ... class B: ... x=2 ... def f(self): ... return x ... return B() ... b=c() b.x 2 b.f() # not 2 1
- Previous message: [Python-Dev] thunks
- Next message: [Python-Dev] thunks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]