lua-users home
lua-l archive

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


Javier Guerra said:
> On Friday 16 September 2005 4:20 am, Rici Lake wrote:
>> This allows you to create a wrapper which is quite flexible:
>>
>> function(env)
>>   in env do
>>     return function()
>>       -- insert code here
>>     end
>>   end
>> end
>>
>> Now every time this factory is executed, it creates a new instance of
>> the
>> embedded code with a different environment.
>
> i don't get how's this different from:
>
> function (env)
>   return (setfenv (function()
>     -- insert code here
>   end, env))
> end
>
> --

It's not significantly different but it allows functions to be immutable,
and still have an equivalent to setfenv.