2

In the wiki page http://wiki.luatex.org/index.php/Writing_Lua_in_TeX there is a promising solution to identify between the different lua(TeX) chunks:

\directlua {<lua code>}
\directlua name {<name>} {<lua code>}
\directlua <number> {<lua code>}

But there is no example. When I add a number, 3, as suggested in the last syntax. There is no compilation error reported but the error message following a lua error is not different : I looked for the number 3 for the faulty chunk but I had the standard :1 reference for the chunk.

How does it work ? Is there an equivalent for luadirect, luaexec, ... ?

  • This is pretty 'low level': I don't think it carries through to the wrappers such as luacode. – Joseph Wright Dec 27 '15 at 19:24
4

Compare these

\directlua name{luachunk}{
print(debug.traceback())
}

\directlua {
print(debug.traceback())
}



\bye

The first produces

stack traceback:
        [string "luachunk"]:1: in main chunk

showing the named chunk in the trace

The second show the default name.

stack traceback:
        [\directlua]:1: in main chunk

Latex (or the ltluatex.tex file for plain tex) has a \newluachunkname to offer a slightly highernlevel interface to this.

|improve this answer|||||
  • 1
    Perhaps add a numerical example? (You need something like \directlua{lua.name[4] = "foobar"}\directlua 4 {print(debug.traceback())} to see the effect.) – Joseph Wright Dec 27 '15 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.