[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setting _ENV in Lua 5.2 when loading a file...?
- From: Michal Kottman <k0mpjut0r@...>
- Date: Thu, 10 Nov 2011 12:03:45 +0100
On 10 November 2011 11:48, Miles Bader <miles@gnu.org> wrote:
> Petite Abeille <petite.abeille@gmail.com> writes:
>> It takes an environment in 5.2:
>>
>> load (ld [, source [, mode [, env]]])
>
> Yeah, but as I mentioned, "load" is kind of annoying to use; having
> "loadfile" take an (optional) environment parameter would be much
> nicer.
I could not find the message on this list, but I remember an
'io.lines' trick to do the job with load:
function myloadfile(filename, env)
return load(io.lines(filename, '*L'), filename, 't', env)
end