Re: TeX syntax?

Allan Adler <ara@nestle.csail.mit.edu>
9 Feb 2007 21:48:51 -0500

          From comp.compilers

Related articles
TeX syntax? rjshaw@netspace.net.au (Russell Shaw) (2007-02-08)
Re: TeX syntax? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2007-02-09)
Re: TeX syntax? adrian@cs.rhul.ac.uk (A Johnstone) (2007-02-09)
Re: TeX syntax? ara@nestle.csail.mit.edu (Allan Adler) (2007-02-09)
Re: TeX syntax? phlucas@f-m.fm (Philipp Lucas) (2007-02-12)
Re: TeX syntax? jhallen@TheWorld.com (2007-02-16)
Re: TeX syntax? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2007-02-16)
Re: TeX syntax? jhallen@TheWorld.com (2007-02-25)
Re: TeX syntax? gjthill@gmail.com (Jim Hill) (2007-02-25)
Re: TeX syntax? rockbrentwood@gmail.com (Rock Brentwood) (2021-04-04)
[2 later articles]
| List of all articles for this month |

From: Allan Adler <ara@nestle.csail.mit.edu>
Newsgroups: comp.compilers
Date: 9 Feb 2007 21:48:51 -0500
Organization: Compilers Central
References: 07-02-024 07-02-029
Keywords: macros, interpreter
Posted-Date: 09 Feb 2007 21:48:51 EST

glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:


> Russell Shaw wrote:
> > Knuths TeX book mumbles something about "registers" that hold things
> > like page numbers or whatever. Where is there a complete list of
> > these registers, uses, and limitations?
>
> I believe the fundamental integer registers are \count0 through
> \count255, but most that are actually used are defined through macros.
> The TeXbook describes them pretty well.
>
> > Knuths TeX book is an abomination, describing lexing and parsing as
> > mouth, gullet and stomach nonsense.
>
> That is pretty important, as in some cases macros change things
> just before they are used. If you get it wrong, they are changed
> too late. Consider \def\x{\y}\x is x defined before it is
> expanded, or not? How about \def\x{\y} \x ?


Knuth's TeX Book is a manual for using TeX. It is a wonderful book.
It is volume A of a 5 volume work whose volumes are:
A. The TeX Book
B. TeX the Program
C. The METAFONT Book
D. METAFONT the Program
E. Computer Modern Typefaces


Volumes A and C are manuals for TeX and METAFONT, respectively. Volumes
B and D are literate documentation of these two programs. TeX and METAFONT
were written in Knuth's WEB system of literate programming. The sources
were therefore WEB files. A web file can be processed in two ways. One
processor for a web file is called weave. When one applies weave to a
web file, one gets a TeX file which is a literate account of the workings
of the program in all detail. When one applies tangle to a web file, one
gets a pascal program which is the program which is being documented by
the TeX file. One gets the program to work by running the pascal program
through pascal. (Of course, to get around the limitations of pascal, one
instead runs the pascal program through p2c to convert it to a C program
and then compiles the C program.)


The book "TeX the Program" is the result of taking the WEB source for
TeX, running it through weave, and then running the resulting TeX file
through TeX. This method of documenting programs is so good that the
resulting documentation is publishable, in this case as the book, "TeX
the Program". Similarly, the book "METAFONT the Program" is the result
of giving the WEB source of METATONT the same treatment.


So, to make a long story short, if you want details about the actual
workings of TeX and METAFONT, at a level that one can't really expect
a manual such as The TeX Book or The METAFONT Book to provide, you should
look at volumes B and D of Knuth's 5 volume masterpiece.


Volume E explains how all of Knuth's computer modern fonts were designed
in case you want to learn the art of designing professional quality fonts.


When they first appeared in the 1980's, I purchased all 5 volumes for $150
and I have never regretted it, nor have I ever stopped learning from them.


If you want to learn more about the concept of literate programming, Knuth
published an article about it and I think there is also a book on it. You
can also follow the newsgroup comp.programming.literate. There are now many
programs for literate documentation of programs. For C programs, Knuth and
Levy developed CWEB, with processors cweave and ctangle instead of weave and
tangle, and these programs have themselves been literately documented using
CWEB. One of the more popular literate programming programs was developed by
Norman Ramsay and is called noweb. It can be used to document just about any
programming language but loses the automatic formatting of code that one gets
with CWEB, although some people have developed packages to compensate for this.
--
Ignorantly,
Allan Adler <ara@zurich.csail.mit.edu>


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.