A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/032832.html below:

[Python-Dev] thunks

[Python-Dev] thunksSamuele Pedroni pedronis@bluewin.ch
Mon, 3 Feb 2003 18:20:42 +0100
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:
>
>   [<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.

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










RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4