lua-users home
lua-l archive

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


On Aug 13, 2014, at 3:00 PM, Coda Highland <chighland@gmail.com> wrote:

>> 
>> Ah, interesting border-case. In fact, even if you DO specify an environment to loadfile() in this case it will be inaccessible to the function.
>> 
>> I’ve not really given it much thought, but a function that declares _ENV as one of its arguments in fact has NO access to the global environment at all so far as I can see (except indirectly via upvalues or other arguments, both of which the caller can control). Is this, then, a Lua idiom for writing (partially) pure functions? With the obvious caveat that such a function is free to call impure functions.
>> 
>> —Tim
> 
> It feels to me more like a "with" block than any sort of functional idiom.
> 
> /s/ Adam
> 

Yes, possibly. In either case it’s just a minor observation.

—Tim