[luatex] loadfile() broken in 0.74.0 (lua 5.2)
Manuel Pégourié-Gonnard
mpg at elzevir.fr
Sat Jan 5 20:09:51 CET 2013
Hi,
With the change to Lua 5.2, loadfile() should accept new arguments, most notably
the third one to provide an environment for the loaded chunk. This argument is
especially useful since setfenv() is removed in Lua 5.2.
However, I'm afraid this argument is ignored by LuaTeX:
mpg at roth ~ % texlua --version
This is LuaTeX, Version beta-0.74.0-2012122510 (TeX Live 2013/dev)(rev 4541)
mpg at roth ~ % head *.lua
==> bar.lua <==
print(_ENV)
==> foo.lua <==
print(_ENV)
local t = { print = print }
print(t)
loadfile('bar.lua', 'bt', t)()
mpg at roth ~ % lua5.2 foo.lua
table: 0x21325f0
table: 0x2138910
table: 0x2138910
mpg at roth ~ % texlua foo.lua
table: 0x1fc4810
table: 0x1fc8eb0
table: 0x1fc4810
Please note that the last line should be equal to the previous one, as is the
case with the stock Lua interpreter. I didn't dig into this, but I would guess
that the additional arguments are lost when LuaTeX replaces loadfile() whith is
own version possibly using kpse.
Best,
Manuel.
More information about the luatex
mailing list