2015-03-08 13:09 GMT+02:00 luigi scarso <[email protected]>: >
>> The behaviour is as if the lines of `myfile.lua` were entered one >> by one in interactive mode. That is to say, the scope of all local >> variables ends at the end of the line they are defined on, unless >> they are inside an unclosed block. This causes a perfectly valid >> Lua script to fail when run by texlua. > > hm, could be...can you give an example ? This was the example: package.path = "./?.lua" local msg, apl = pcall(require, "gnuapl") print( msg,apl) print(apl.what(_G)) print(apl.what(package.loaded)) which produced the following output $ texlua xxx.lua true table: 0x276c3c0 ./gnuapl.lua:157: attempt to index global 'apl' (a nil value) Removing `local` makes it work. However, staring at the above made me realize that the error arises because a global variable `apl` inside the module is not defined in time, but since the call defines it globally, by the time `what` is called, it is defined in the second case. So texlua is absolved. Sorry for the noise. Dirk However
