|
On 06/16/2011 12:03 AM, Lorenzo Donati 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).
I second this idea, though callin(env, f, ...) might be a better name to fit with existing function names. It would also make some DSL cases easier where the same function needs to be re-evaluated multiple times in different environments.
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). -- Lorenzo
-- Regards, Matthew "LeafStorm" Frazier http://leafstorm.us/