[Dev-luatex] Assignments in Lua

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Fri May 23 13:33:28 CEST 2008


> > Are there any ideas on how to extend TeX's syntax? More than nine
> > parameters (if that is useful)? Parameter matching using regular
> > expressions or Lua patterns? Optional parameters without having to
> > use \futurelet (expandable, no fixed catcodes)?
> As Hans said, this is low priority, but it would be simple to
> map simple lua functions to simple tex csnames.

Expanding on that: TeX's csnames could be represented in Lua as
the table "tex.cs"; each entry either contains a TeX macro (a
userdata type in Lua), a TeX primitive or a Lua function. "Calling"
the cs inside TeX would then check its type and perform the
appropriate action.

That would do away with the need for a glue macro which is currently
required for calling Lua functions from TeX (using \directlua).

> Once inside a lua function, you could then call token.get_next()
> and possibly some other helpers to do more advanced stuff.  There
> could well be a frontend to fetch the wanted arguments using
> something like a (fictional) token.match function.


	local optional
	if token.isnext("[") then
		optional = token.match("[", "]")
		optional = "default value"

where token.match correctly handles characters with catcodes 1 and 2
(most likely braces).

> We have not actually given this any thought yet, and the most
> thing is therefore not coding, but coming up with a nice interface.
> Suggestions in that area are certainly welcome.

There was a paper a few years back on extending TeX that discussed this
subject. I do not recall the name of the paper anymore, most likely it
was a Tugboat article. I will look for it at home and post it if anyone
is interested.

> Best wishes,
> Taco


More information about the dev-luatex mailing list