[luatex] luatex manpage not quite the status quo

Dirk Laurie dirk.laurie at gmail.com
Sun Mar 8 13:33:43 CET 2015

2015-03-08 13:09 GMT+02:00 luigi scarso <luigi.scarso at gmail.com>:

>> 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)


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.



More information about the luatex mailing list