[Python-Dev] thunks

M.-A. Lemburg mal@lemburg.com
Tue, 04 Feb 2003 20:51:33 +0100


Tim, what have you been putting into Guido's coffee the last few
days ? Colons seem to have grown magical expressiveness and now he
even likes lambdas ;-)

Guido van Rossum wrote:
> 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:
> 
>   [<variable> =] <expression>:
>     <block>
> 
> Thunk introducing a new local scope:
> 
>   [<variable> =] <expression> lambda:
>      <block>
> 
> (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:
> 
>   [<variable> =] <expression> lambda <arguments>:
>      <block>
> 
> 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.
> 
>   [<variable> =] <expression> lambda:
>     <block>
>   and <expression> lambda:
>     <block>
>   ...
> 
> Disclaimer: this is a half-baked idea.
> 
> --Guido van Rossum (home page: http://www.python.org/~guido/)

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/