[Dev-luatex] Can \directlua be nested?

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Thu Jan 31 13:29:45 CET 2008


Hello,

> > can \directlua be nested, i.e.
> > 
> > 	\directlua0{\directlua0{tex.print('foo()')}}
> > 
> > to call Lua function 'foo'?
> 
> \directlua is never called recursively, even though it 
> sometimes looks like it is. The example above is 
> syntactically wrong, but this works (ignoring \catcode issues):
> 
>    \directlua0{tex.print('\directlua0{foo()}')}

I'm not sure why: In your example, the second \directlua is
expanded while the first \directlua expands its argument, just
like in my example. You would have to surround it with
\unexpanded or \detokenize (and \luaescapestring because of
the backslash) to pass it unmodified to tex.print.

> however, executation is serialized. The output of tex.print 
> is not seen until the end of the outer \directlua is reached.

Ah. So \directlua first reads its second parameter and then expands
it completely, instead of expanding tokens until it reaches the
closing brace delimiting its second parameter, and therefore does
not include the output of tex.print? (just like \edef does)


> Best wishes, Taco

Jonathan



More information about the dev-luatex mailing list