[Dev-luatex] A few idle questions...

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Wed May 7 14:18:16 CEST 2008


> Are there any practical experiences with Coco in LuaTeX already?

Even though I would not call them "practical":

I once used coroutines in the file reading callback to convert a
text file to TeX using coroutine.yield to return each converted
line of text as well as a short preamble and a postamble. I posted
the example to the LuaTeX wiki:


It works like a charm (even though the example is not very useful).

I was also thinking of implementing a LaTeX environment using a
coroutine, so that there is only a single function that yields after
\begin and is resumed by \end. That way, the \end code can access
local variables of \begin.


function env()
	% \begin:
	local answer = 42
	tex.sprint("Beginning the environment")
	% \end:
	tex.sprint("Ending the environment with ", tostring(answer))

	\directlua0{currEnv = env()}%
	\directlua0{coroutine.resume(currEnv) currEnv = nil}%


This results in (or at least should result in):

Beginning the environment ... Ending the environment with 42

> All the best,
> David


More information about the dev-luatex mailing list