Idea: "Frozen" inner function

Michael Butscher mbutscher at gmx.de
Mon Nov 27 11:04:10 PST 2006


Steve Horne wrote:
> But...
> 
> 1  This is the variables for the outer function, not the inner
>    function. You put those variables in the stack frame whether
>    the inner function object is actually created or not, and
>    several inner function objects could be created that all refer
>    to the same stack frame.
> 
> 2  It doesn't use the term closure to describe this.
> 
> So basically, I thought I knew what I was talking about, but now I'm
> not so sure.
> 
> Maybe Python is doing the (1) thing, but that leaves me wondering how
> come my existing code is working.

Before closures were introduced in Python (about 2.2 or so), it was a 
common idiom to write:

lambda a=a: ...

to access an outer variable a. Maybe you are using something like that.


> Incidentally, Amazon seems to have the full text of the book if you
> want to check exactly what it says, but stepping through the pages
> one-by-one to get to the relevant section (around page 490-ish) is
> painful.

This would be really tedious, especially with my dialup internet 
connection.



Michael



More information about the Digitalmars-d mailing list