[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: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 10 Nov 2011 10:16:54 -0200
> On Nov 10, 2011, at 6:31 , Roberto Ierusalimschy wrote:
> > return load(io.lines(filename, 2^12), filename, 't', env)
> >
> > seems reasonable.
> >
> > -- Roberto
>
> It took me a minute to realize what `io.lines(filename, 2^12)` meant. loadfile's signature is currently just `loadfile([filename])`, why can't it be `loadfile([filename[, env]])` or `loadfile([filename[, mode[, env]]])`?
It certainly can. The point is whether it should ;) It increases both
the implementation and the manual (but by minimal amounts).
The change also breaks some code, like this one:
loadfile(string.gsub(filename, '%.', '/'))
The result is a quite confusing error when running the chunk:
temp:1: attempt to index upvalue '_ENV' (a number value)
-- Roberto