Lua files as examples
Urs Liska
lists at openlilylib.org
Fri Jul 19 13:01:51 CEST 2019
19. Juli 2019 12:41, "Ulrike Fischer" <news3 at nililand.de> schrieb:
> Am Fri, 19 Jul 2019 09:11:50 +0000 schrieb Urs Liska:
>
>>> On another front:
>>
>> require(subfolder.module-name) from the main .lua file.
>>> Does that actually work?
>>
>> I don't really know,
>
> Yes it does. See e.g. the graphdrawing library in
> \texmf-dist\tex\generic\pgf\graphdrawing\lua\pgf\gd which uses a
> similar layout.
>
> But I remember of a least one case where it lead to a name clash (I
> think in context but I'm not sure).
My initial test (requiring the module without the (relative) path) did find the submodule, so I assume the module is not found by its relative path but through the fact that it is in the (Lua/kpsewhich?) search path. If that's the case than any other client would find it as well, and depending on the arbitrary search order ther wrong module might be loaded.
If that assumption is correct then a) I don't have to worry about the submodules to be found and b) I *do* have to worry about naming them uniquely, which I'll immediately take care of.
>
> If possible at least the main lua-file should contain a declaration,
> so that it shows up in the log. luaotfload e.g. has this:
>
> local ProvidesLuaModule = {
> name = "luaotfload-init",
> version = "2.98",
> date = "2019-07-04",
> description = "luaotfload submodule / initialization",
> license = "GPL v2.0"
> }
>
> if luatexbase and luatexbase.provides_module then
> luatexbase.provides_module (ProvidesLuaModule)
> end
>
The modules all have such a declaration, which I make heavy use of for reporting input errors.
>>> If you have a preference, the runtime .lua files can end up either under
>>> scripts/ or under tex/. Let me know. --best, karl.
>
>> I don't know much about the TDS, but it seems somewhat natural that they are under scripts/.
>
> luaotfload-tool.lua is in scripts as it is connected/used by the
> command line tool luaotfload-tool.
>
> The other lua-file of luaotfload are in tex/luatex as they are used
> by documents.
>
Ah, this makes sense. So my lua files are *not* intended to be used from the command line, only from documents/packages. So they should rather be placed in the tex/luatex subtree.
Best
Urs
> --
> Ulrike Fischer
> http://www.troubleshooting-tex.de
More information about the tex-live
mailing list