lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9 August 2010 08:40, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> [...] (One could use debug.upvaluejoin to give it a new upvalue,
>> but this is an even worse hack in my opinion.)
>>
>> I would rather avoid changing the file any to accomplish this (it
>> messes with debug output from errors and whatnot) -- that is, I don't
>> want to add a function to each script that lets me change the
>> environment dynamically. Does anyone see a better way to do this?
>
> Basically you want to break a function abstraction, interfering from the
> outside in what the function does inside. This is a hack, no matter how
> you implement it. This kind of thing should not be a regular operation
> in the language (as it was with setfenv).

Are you saying that this is not something you should do, or that if
you decide to do something this extreme (which fundamentally changes
the behaviour of specific scripts you load) you shouldn't be afraid of
using debug.upvaluejoin in the implementation?

IMO when specified as a well-defined feature of a framework, this is
an extremely useful use-case.

    henk