[Dev-luatex] Can \directlua be nested?

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Fri Feb 1 11:13:03 CET 2008


> > Thanks for your reply. When coming home yesterday, I experimented
> > a little bit, and the results do not seem to match your answer.
> > In Plain TeX:
> > 
> > 	\directlua0{%
> > 		tex.sprint('A')%
> > 		\directlua0{tex.sprint('B')}%
> > 		tex.sprint('C')%
> > 	}
> > 
> > This results in "LuaTeX error [string "luas[0]"]:1: attempt to index
> > global 'Btex' (a nil value)". 
> Yes, that's what I meant to say (you input is invalid).

Well, it is invalid, because it generates invalid Lua code (which would
not be the case, if a table "Btex" existed and contained a field

> We have a bit of a communication error, I'm afraid.

Yes, unfortunately my original questions was not clear enough. In
the above example, I do not want to output "B" after the outer
\directlua (and between "A" and "C"), but I want to insert it
*into the Lua code* executed by the outer \directlua (as the
example in your answer to Hans does: It inserts "tex.sprint('B')"
between "tex.sprint('A')" and "tex.sprint('C')" in the outer

Or, in my original example


I wanted the inner \directlua to insert "foo()" into the Lua code
executed by the outer \directlua (so that the outer \directlua
calls function "foo" with no parameters). And judging from your answer

| \directlua does indeed read the entire braced argument at once

I thought this would not be possible. Now I'm wondering if this
possibility of nesting \directlua is accidental (and maybe leaks
memory) or not.

> Best wishes,
> Taco

Thanks in advance,

More information about the dev-luatex mailing list