[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using lexical environments (was setfenv/getfenv)
- From: Leo Razoumov <slonik.az@...>
- Date: Tue, 12 Jan 2010 15:09:20 -0500
On 2010-01-12, Nevin Flanagan <Alestane@comcast.net> wrote:
> I strongly favor the transition to lexical environments. What I think would be the
> most versatile addition to this would be the addition to the lua_ API of a function
> such as "lua_pushclosurecopy" or something similar, that would create on the
> stack a copy of the closure at a given index, with the same code and upvalues
>but as a separate object that could be passed or collected separately. This would
> make it trivial to add a function inside Lua that would create a copy of a closure
> with its own environment, without decompiling or recompiling it. This would also
> mean that code could keep a closure without the fear that a new environment
> could be forced on it, since it would not know about the copy.
I like your approach of "clone a closure". It seems to address my issues nicely.