[Dev-luatex] writing a rmdir function in texlua

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Fri Apr 4 10:05:57 CEST 2008


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



More information about the dev-luatex mailing list