[luatex] print versus tex.print

Paul Isambert zappathustra at free.fr
Mon Jan 23 15:47:08 CET 2012


luigi scarso <luigi.scarso at gmail.com> a écrit:
> 
> 2012/1/23 Herbert Voss <Herbert.Voss at fu-berlin.de>
> 
> > this works with Lua
> >
> > table.foreach(os.date("!*t"),**print)
> >
> > but when I replace print with tex.print I'll get
> > an error because tex.print doesn't know how to
> > handle the last boolean value of the date table.
> >
> > \directlua{table.foreach(os.**date("!*t"),tex.print)}
> > \bye
> >
> > ! LuaTeX error no string to print
> > stack traceback:
> >        [C]: ?
> >        [C]: in function 'foreach'
> >        <\directlua >:1: in main chunk.
> > l.1 ...ua{table.foreach(os.date("!***t"),tex.print)}
> >
> >
> > I can handle the last table entry as a special case, no problem.
> > But is there an easy way to catch a boolean value?
> >
> > Herbert
> >
> 
> \directlua{table.foreach(os.date("!*t"),function(...)
> tex.print(tostring(...) end)}
> \bye

Or use a test like "type(<arg>) == 'boolean'". Note that table.foreach
is deprecated in Lua 5.1 and should be removed from 5.2 (see:
http://lua-users.org/lists/lua-l/2010-11/msg00661.html). And LuaTeX
should sooner or later switch to Lua 5.2, with goto's and other funny
things.

Best,
Paul



More information about the luatex mailing list