
TUGboat, Volume 0 (9999), No. 0 1001
TiCL: the Prototype
Didier Verna
Abstract
While T
E
X is unanimously praised for its typesetting
capabilities, it is also regularly blamed for its poor
programmatic offerings. Several solutions have been
proposed to modernize T
E
X on the programming
side. All of them currently involve a heterogeneous
approach in which T
E
X is mixed with a full-blown pro-
gramming language. This paper advocates another,
homogeneous approach in which the Common Lisp
language is used to implement a T
E
X-like typesetting
system. The underlying implementation language
serves both at the core of the program and at the
scripting level, hence removing the need for program-
matic macros on top of typesetting commands. A
prototype implementation is presented.
1 Introduction
Last year at TUG 2012, we presented some ideas
about using one of the oldest programming lan-
guages (Common Lisp [
5
,
1
]), in order to modernize
one of the oldest typesetting systems (T
E
X). The
idea behind the term “modernization” here is to re-
tain the quality of T
E
X’s output (the typesetting
part) while providing a more consistent and power-
ful programmatic API. This idea is not new and
has led to several attempts at mixing T
E
X with
a full blown programming language, such as with
eval4tex
1
and sT
E
Xme
2
(Scheme), PerlT
E
X [
6
,
7
]
(Perl) and QaT
E
X/PyT
E
X [3] (Python).
While these approaches to modernization are
useful for the end-user who wishes to write his own
set of macros in a more practical way, there is more
to modernization than just the programmatic API.
Another room for improvement lies in the design and
flexibility (or lack thereof) of T
E
X’s internals. T
E
X
is an old program written in a way that doesn’t meet
today’s standards. For example, it’s full of corner
case optimization that could arguably be considered
obsolete on modern architectures, it lacks a potential
Object Oriented design that would make it easier to
extend it or even modify it, for example in order to
experiment with alternative typesetting algorithms.
Approaches such as LuaT
E
X
3
attempt to address
both aspects of modernization: mixing Lua with T
E
X
provides both a scripting language on the surface
layer, and access to T
E
X’s internals at the same time.
1
http://www.ccs.neu.edu/home/dorai/eval4tex/
2
http://stexme.sourceforge.net/
3
http://www.luatex.org
In our opinion, this approach still suffers from the
following drawbacks.
1.
Lua is not a full-blown, industrial scale program-
ming language. It’s a scripting language with a
limited set of programming paradigms.
2.
The resulting system is heterogeneous. It’s a
complex mixture of two different languages pro-
viding some limited level of introspection / in-
tercession. Put differently, accessing T
E
X’s in-
ternals from Lua requires manual plumbing.
3.
Even with a sufficient amount of introspection
/ intercession, what you end up with still is
“good ol’T
E
X”, with its lack of modern software
engineering concerns.
Last year at TUG 2012, we advocated the use
of Common Lisp as a better alternative for all these
aspects of “modernization”. We explained that Com-
mon Lisp is both a full-blown industrial language
suitable for a rewrite of T
E
X, and a scripting lan-
guage suitable as a replacement for T
E
X macros. We
then demonstrated the benefits of this homogeneous
approach, in which a single programming language is
involved: a re-implementation of T
E
X with modern
software engineering in mind, in a fully reflexive lan-
guage such as Common Lisp, would provide a system
very convenient for extension and / or modification
(hence experimentation). For more information, the
reader is referred to [8].
The purpose of the present paper is to apply the
ideas expressed last year in an actual prototype, in
order to assert the validity of the proposed approach.
Section 2 presents a general overview of the proto-
type. Section 3 on the next page gradually builds the
prototype’s programmatic layer, that is, the interface
that an author could use in order to actually program
a document. Section 4 on page 1005 presents an ad-
ditional layer on top of the programmatic one, called
the “textual layer”, in which plain text constitutes
the main entry, and calls to the programmatic layer
need to be escaped. Finally, section 5 on page 1006
illustrates the advantages of the proposed approach
in terms of extensibility, by enriching the prototype
with a rivers detection feature in a non-intrusive way.
The code for the prototype itself, along with all
the examples presented in this paper is available on
GitHub
4
.
2 Overview
One (obvious) conclusion from last year was that
re-implementing a complete T
E
X-like typesetting sys-
tem is a huge task. In particular, even for just a
4
https://github.com/didierverna/ticl-for-TUG2013
TiCL: the Prototype