[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Patrick Donnelly <batrick@...>
- Date: Thu, 16 Jun 2011 08:55:49 -0400
On Thu, Jun 16, 2011 at 12:03 AM, Lorenzo Donati
<lorenzodonatibz@interfree.it> wrote:
> Since this "setting env for a function" seems not too rare (both for
> efficiency reasons - as Patrick said - or for coping with DSL parsing, as in
> my usual case), I wonder whether It could be useful to provide a library
> function such as runin(env, func) that will run func in the provided
> environment (and maybe this could also bypass the limitation that debug info
> should be present, removing a source of indeterminacy when using Sergei's
> replacements).
It's been said elsewhere by the authors that they don't believe any
type of environment tampering is okay for functions. That would
clearly include any sort of "runin" function. I agree with this
mentality.
My proposal corrects what I believe to be a lacking in both Lua 5.1
and 5.2 where you cannot create multiple closures of the same
load-compiled function. Setting _ENV in the generator is just icing on
the cake.
> Probably this could cope with most of the complaints of a missing
> setfenv/getfenv in 5.2 (I don't remember any other use case coming up in the
> list which wasn't covered elegantly by other 5.2. features).
As said above, this isn't just a 5.2 problem.
--
- Patrick Donnelly