Idea: "Frozen" inner function

Michael Butscher mbutscher at gmx.de
Tue Nov 28 05:12:08 PST 2006


Steve Horne wrote:
> On Mon, 27 Nov 2006 20:04:10 +0100, Michael Butscher
> <mbutscher at gmx.de> wrote:
> 
> >Steve Horne wrote:
> 
> >> 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.
> 
> No. I used to, but it was a big relief when I didn't need to any more.
> 
> I'm not so sure now that I change variables much after using them like
> this.

Me too :-)

It seems that full-blown closures with live access to outer variables 
(as long as the outer function exists) are of much rarer need than one 
might think at first.



Michael



More information about the Digitalmars-d mailing list