Jonathan Sauer wrote:
Hello,
trying out the LuaTeX snapshot 20070820, I have a couple of questions:
- Is it safe to add to the LuaTeX library tables (tex, callback), i.e. a callback.push function? Or should these support functions have their own table? ("callback_utils")
you can indeed use those tables as any table, i.e. function tex.mystuff() ... end is legal however, there is no guarantee that future versions of luatex will not use the same names as you do; even if (widespread) macropackages will have their tex.myfunction spread all over the world, future luatex's may define its own myfunction in the tex namespace; of course one can save its meaning before redefining it; so ... it is possible but may have future side effects
- How do I generate an error when inside Lua code? I could use tex.write("\\errmessage{...}"), but then the error would only be generated after the Lua code has finished executing, and after any TeX code created previously using tex.write et.al. has been executed.
- assert - just print messages using texio.write_nl - os.exit() also works
- How do I access control sequences from Lua code? If I have a macro \test, how would I get the tokens of this macro when inside Lua? (without passing them from TeX) Is there a table tex.macro, just like the tex.count, tex.toks etc. tables?
no, you print them to tex using tex.print and tex.sprint; you're either is lua or in tex; something in between would become extremely messy Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------