Hello,
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.
This is also true in lua interpreter itself, I just copied the code.
lua.exe is a bit weird: error() does not generate an interactive error, even though it does set a non-zero return value:
[taco@ntg Taco_Test]$ lua -e 'error()' [taco@ntg Taco_Test]$ echo $? 1 [taco@ntg Taco_Test]$
That is weird indeed. I noticed that it also does not stop the program.
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 }
This looks a lot better, but I would opt to keep the quotes, or output text in <>'s, like Knuth does sometimes (no strong feelings about that though. The literal "string" is definately overkill).
Maybe <> would be better, because there is less chance to confuse it with native code's "[C]".
I will also try if I can some equivalent of line numbers, maybe like so:
stack traceback: [C]: in function 'error' <Test>:4: in function 'd' <Test>:3: in function 'c' <Test>:2: in function 'b' <Test>:1: in function 'a' <Test>:6: in main
Actual input line numbers probably won't work because there can be code-generated token lists etc., but relative line numbers like this would definately be better than always '1'.
I'm not sure if that is possible, since TeX's input processor converts line endings to spaces when reading \directlua's <general text>, so Lua's loadstring only sees a single long line (which is also why Lua comments do not work inside \directlua). You would have to modify this behaviour to keep the line endings (maybe temporarily change the catcode of ^^M to "other"?). But maybe this is better handled by a macro package by switching to an appropriate catcode table. OTOH, due to the assignment, this macro would not be completely expandable, like \directlua is: % Assume \directlua@cct is the appropriate catcode table % #1 = Options + Lua state, #2 = Code \protected\def\mydirectlua{% \begingroup% \catcodetable\directlua@cct% \mydirectlua@% } \long\def\mydirectlua@#1#2{% \endgroup% \directlua#1{#2}% } (of course, \catcode`^^M=12 might be easier than a dedicated catcode table, especially on memory consumption) What do you think?
Cheers, Taco
Jonathan