lua-users home
lua-l archive

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


On Thu, Aug 15, 2013 at 11:42 AM, Enrico Colombini <erix@erix.it> wrote:
>  Found. Here it is: (Luiz)
>> You could write your function to be run in different environments:
>>
>> function f(_ENV,...)
>>         ... -- code that never even mentions _ENV!
>> end

Yep, that's the trick!  And the _cool_ thing is that writing functions
like this (or often compiling them as a wrapper for an expression)
does not in any way interfere with 5.1's setfenv.  So you can have it
both ways with a if statement....

(This idiom will actually be faster than the 5.1 pattern)

(switching subject line to match the ... subject)