[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Looking for real-world internal Lua DSL examples
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 22 Sep 2013 19:20:03 +0200
2013/9/22 Andrew Starks <firstname.lastname@example.org>:
> On Sunday, September 22, 2013, Alexander Gladysh wrote:
>> I'm writing an overview section for documentation of our new
>> open-source Lua DSL building library (to be announced). And I'm
>> looking for real-world examples of internal Lua DSLs.
>> I already used Premake and Squish, and some from our private stuff
>> that you might remember from my talk at Lua WS'11, but I remember
>> seeing more out there :-)
>> So, if you remember anything that can be remotely considered an
>> internal DSL in Lua, even ad-hoc one, please share — either as a link
>> or as a quote if it is something private (and you allow me to quote it
>> in the docs).
> I'm trying to find the LuaTeX mode in which you could write... I believe it
> was LaTeX, but it may have been ConTeX... directly in Lua, more or less
> (often much less).
> Does anyone have a more working knowledge of what I'm getting
> at here? I'll keep looking for it.
Well, LuaTeX is where I first heard of Lua, so I'll discharge that
debt of gratitude by replying to this request.
LuaTeX is a TeX engine, i.e. it can replace the most basic rock-bottom
TeX, but it can compile to PDF and has the ability to invoke Lua
scripts. You say
and what's inside gets passed to a built-in Lua interpreter which
has quite a few extra modules loaded. In particular, there is a
`tex` module, and `tex.write` sends a stream of characters to be
interpreted as TeX after the \directlua command is done. It's a
little more complicated than that: the Lua code is first read by the
TeX interpreter, which will expand TeX macros found in the code,
and is almost insensitive to whitespace. I.e. you use TeX to
preprocess your Lua, which it turn produces more TeX.
LuaTeX uses Lua in the first instance to make life easier for the
TeX developers, but it is available for other users to exploit as
All TeX flavours are just macro packages that sit on top of the
TeX engine, so LuaLaTeX is standard LaTeX running on LuaTeX,
etc. ConTeXt is different, in that it has been using Lua for a longer
time and in fact the current ConTeXt can't run on top of any of
the other TeX engines.