TeX (and all newer engines) has the primitive \show which helps me probe macros, and most of the time is enough to understand/remember the implementation (rather than having to go back to the source code).

Is there something similar for Lua commands? For instance, Heiko Oberdiek has written replacements for some pdfTeX primitives in LuaTeX, and I'd like to get more information about them using some hypothetical \showluatexcmd macro.

\input pdftexcmds.sty

1 Answer 1


I seriously doubt that there is something similar for Lua, but you can do the following to find out where the function is defined (to get to the source code).

\directlua{ require("showluatexcmd") }

\input pdftexcmds.sty

and the file showluatexcmd.lua:


function show( fun )
  local debuginfo = { "source","linedefined","what" }
  for _,v in ipairs(debuginfo) do
    texio.write_nl(string.format("%20s=%q", v, debug.getinfo(fun)[v]))

One could extend this probably to directly load the function and display it. But in most cases this won't help as there are a lot of functions that are short and call other functions.

A sample output is

            what="Lua" )
  • 1
    there is also "lastlinedefined", so you could potentially print a portion of the source file .. Feb 1, 2012 at 8:36
  • I was hoping for something similar to Python's dis module. Actually, luac -l may help. Also, what does "what" mean in the debug info? Feb 1, 2012 at 14:10
  • @BrunoLeFloch a) what is Python's dis module? b) What describes where the function is defined: a "C" function or a "Lua" function (I remember seeing other things written there)
    – topskip
    Feb 1, 2012 at 14:29
  • @Patrick: sorry, the dis module is a disassembler: dis.dis(myfunction) will print (pseudo-)assembly code for myfunction. It seems luac -l does that too, but on compiled Lua files (see the well-hidden link in my previous comment), so I'm not sure whether it could be used for LuaTeX. Feb 1, 2012 at 14:39

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.