4 Apr
2008
4 Apr
'08
10:05 a.m.
Hello,
Thanks, also big thnaks for the lua crash course ;-) I will try to remember using local everywhere ;-)
Once you start, it is impossible to stop; you want to make every variable local ;-)
That is actually possible. You simply have a module add its definitions not to the global table, but to a local one which is then returned: local M = { } M.foo = function(...) ... end ... return M The caller then does: local mymodule = require("mymodule") mymodule.foo(...) In TeX, you could do the same thing: \directlua0{require("mymodule").foo(...)} (of course this only works because require has a global variable storing the return value of all loaded modules. So some globals are still required.)
Arthur
Jonathan