[luatex] \Ucharcat

Hans Hagen pragma at wxs.nl
Sun May 24 11:07:00 CEST 2015


On 5/23/2015 6:29 PM, David Carlisle wrote:

> Thanks for the code suggestions, helpful to get a feel of the interface
> for getting tokens back from lua, I need to play with \luafunction more:-)

It has some drawbacks, for instance you need to make sure the functions 
are registered and lua code like that is not stored in the format (one 
can of course write code for that) so it needs runtime initialization. 
So using a \directlua is not bad per se.

You can also chain like this:

\directlua{

	function one()
           tex.sprint("first")
           tex.sprint("\\directlua{tex.print("two()")")
         end
         function two()
           tex.sprint("second")
         end
}

\directlua{one()}

and do the push/pop catcode in one and two. The performance difference 
is small, in fact you can measure it being a bit slower than using 
\luafunction but on the average \directlua calls are neglectable 
compared to the rest of the typesetting. So go for what is most 
convenient and readable (\luafunctions are harder to trace for instance 
as they are kind of anonyumous, while for \directlua you see errors more 
clearly).

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list