Hello,
[setting \directlua's chunk name]
This allows you to do stuff like this:
\directlua name {\jobname-\the\inputlineno} 0 {error('test')}
Great! Thanks! I'll try it this evening (your example is especially intriguing).
Well, I tried it, and apart from some minor nitpicks it works
perfectly, as does <error>'s stack traceback:
--------------------------------------------------------------
%&luatex
% \directlua0{error()} % A
% \directlua0{error('')} % B
\directlua name{Test} 0{ % C
function a() b() end
function b() c() end
function c() d() end
function d() error('') end
a()
}
\end
--------------------------------------------------------------
(A) results in:
This is LuaTeX, Version snapshot-0.25.3-2008042918 (Web2C 7.5.6)
(Error2.tex
! LuaTeX error .
l.4 \directlua0{error()}
% A
?
(B) results in:
This is LuaTeX, Version snapshot-0.25.3-2008042918 (Web2C 7.5.6)
(Error2.tex
! LuaTeX error [string "\directlua0"]:1:
stack traceback:
[C]: in function 'e
rror'
[string "\directlua0"]:1: in main chunk.
l.5 \directlua0{error('')}
% B
?
Of course, (A) is not a really relevant case, since no-one in their
right mind would call <error> without an appropriate message. Still,
it is a bit puzzling why there is no traceback.
Also note how the traceback is wrapped in a slightly weird way. Most
likely this is because it is written using
else { /* out = [string] */
202c202 < bufflen -= sizeof(" [string \"...\"] "); ---
bufflen -= sizeof(" [...] ");
204c204 < strcpy(out, "[string \""); ---
strcpy(out, "[");
211c211 < strcat(out, "\"]"); ---
strcat(out, "]");
This results in: This is LuaTeX, Version snapshot-0.25.3-2008042921 (Web2C 7.5.6) (Error2.tex ! LuaTeX error [Test]:1: stack traceback: [C]: in function 'error' [Test]:1: in function 'd' [Test]:1: in function 'c' [Test]:1: in function 'b' [Test]: 1: in function 'a' [Test]:1: in main chunk. l.14 } ? What do you think? Jonathan