diff options
Diffstat (limited to 'usergrps/uktug/baskervi/3_1/a-fine.tex')
-rw-r--r-- | usergrps/uktug/baskervi/3_1/a-fine.tex | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/usergrps/uktug/baskervi/3_1/a-fine.tex b/usergrps/uktug/baskervi/3_1/a-fine.tex new file mode 100644 index 0000000000..0aab208bf7 --- /dev/null +++ b/usergrps/uktug/baskervi/3_1/a-fine.tex @@ -0,0 +1,174 @@ +% FINE: \tugboat\teach.tex +% +% Jonathan Fine +% 203 Coldhams Lane +% Cambridge +% CB1 3HY +% +% Tel 0223 215389 +% +% Email: J.Fine@pmms.cam.ac.uk + +\title{What should we teach \TeX?} +\author[Jonathan Fine]{Jonathan Fine\\Cambridge} + +\begin{article} + +\begin{quote} +A `virgin' \TeX\ system that has no macros is like a newborn baby +that has an immense amount to learn about the real world; but it is +capable of learning fast. \\ +{\em The \TeX book} p.342 +\end{quote} + + +\section{Introduction} + +I would like to use this article as an opportunity to explain to the +UK \TeX\ community what it is that am doing, and have been trying to +do, for the last two years. This will not be easy -- the subject +matter can be difficult and unfamiliar, even to myself -- and so the +reader's indulgence is asked for. + +I am working in what the cosmologists might call the first seconds of +the universe. More exactly, I am writing macros that are to be +loaded even before the like of \verb|plain| or \LaTeX\ are to be loaded. +Most users are concerned with later time, when \TeX\ is generating a +\verb|dvi| file from the author's typescript. + +\section{Macro packages} + +Before explaining further, a few words about \verb|plain| and \LaTeX. In +the beginning was \verb|plain.tex|, which consists of 1229 lines. \LaTeX\ +2.09 consists of 1318 lines in \verb|lplain.tex|, the \LaTeX\ version of +plain, together with 8565 lines in \verb|latex.tex| and 995 lines in +\verb|lfonts.tex|. Although the new \LaTeX\ 3 is not yet available, two of +its intended support macro files, \verb|doc.doc| and \verb|docstrip.doc|, weigh +in at 4554 and 2918 lines respectively. (In fairness, it should be +added that the relative quantity of documentation is greater in the +later files). + +A file such as \verb|plain.tex| has two purposes. One is to place +particular macros etc.\ into the memory of \TeX -- to teach it +something. The other is for us to read, so that we might know what is +being done. From the beginning there has been a tension between +these two functions. +In the \TeX book Knuth does {\it not\/} list \verb|plain.tex| verbatim. On +p.342 he explains: +\begin{quote} +``Un-optimized versions of the macros are easier for humans to +understand, so we shall deal with those; \verb|plain.tex| contains +equivalent constructions that work better on a machine.'' +\end{quote} +and further explanation is given at the top of p.348. + +This tension between human comprehension and machine efficiency has +grown with time, and is commonly expressed by the complaint, that +\TeX\ is difficult to program, or inadequate as a programming +language. (I personally like the \TeX\ macro language, and believe +its basic conception to be sound. However the complaints are real, +for they have a basis in experience). + +\section{A new point of view} + +If \TeX\ were a new microprocessor with its own instruction set, then +specialist developers would produce language tools. These would +compile higher level commands into \TeX's instruction set. Such +tools would relieve much of the tension and difficulty in programming +\TeX. + +Two years ago I began such a process of development for \TeX. If I +had known then the work involved, I may not have started. It has now +born its first fruit, the \verb|\noname| package, which is a valuable tool +for the author of \TeX\ macros. + +Briefly, \verb|\noname| removes many of the irritations of \TeX\ by +implementing an extension of the \TeX\ programming language. Files +written in the \verb|\noname| dialect of \TeX\ can be loaded directly into +\TeX's memory, or compiled into a form where they can be loaded at +high speed and with minimal overhead. The situation is similar to +that of a language interpreter and compiler. The \verb|\noname| package, +and macros written using \verb|\noname| are completely compatible with, +and independent from, the standard packages such as \verb|plain| and +\LaTeX. + +\section{About {\tt noname}} + +Here are some of the features of \verb|\noname| which ease the +programmer's task. +\begin{itemize} + \item It is easy to write long comments -- every line not beginning with a + space character or a hash \verb|#| is ignored. + \item Lines beginning with a \verb|#| are {\it hash commands}, which control + conditional compilation, much as in {\it C}. + \item All white space in macro code is ignored. However, the escape + character \verb|~| will {\it always\/} produce an ordinary space + character, even after a control word or a previous space producing + \verb|~|. + \item As well as letters and \verb|@| the digits \verb|0..9|, the underscore \verb|_| and + the colon \verb|:| can be used to form a control word. This does not + conflict with the normal use of these characters. + \item Ready access is provided to active characters, and other characters + with unusual catcodes. + \item Ready access is provided to control sequences which store numeric + constants such as $-1$, $0$, $16$ and $255$. One simply types \verb|[-1]| + in place of \verb|\m@ne|, and \verb|[16]| instead of \verb|\sixt@@n|. + \item Support is provided for the powerful control macros \verb|\break|, + \verb|\continue|, \verb|\return|, \verb|\CASE| and \verb|\FIND|. + \end{itemize} + +This is only the beginning. Intended, planned, and under +development enhancements include the following. +\begin{itemize} +\item Indexing and cross-reference utilities. +\item Interactive tutorial material for teaching how macros and primitive +commands work. This will use the next item. +\item A {\it single-step debugger\/} which will execute \TeX\ code one step +at a time. For example, the expansion of an expandable token such as a +macro is a single step, as is the execution of a primitive command. +\TeX\ acts on a stream of tokens. After each step the (changed) +stream of tokens is displayed and the user regains control. +\item A powerful {\it pretty printer\/} for typesetting source files +written in the \verb|\noname| dialect of \TeX. This will require zero or +minimal additional markup. +\item Named parameters for macros. This means one can write +\begin{quote} +\verb|\def\mymacro #\text ... | +\end{quote} +instead of +\begin{quote} +\verb|\def\mymacro #1 ... | +\end{quote} +when coding a macro. This makes it easier for a human to read the +macro. +\item Support for modules, with private and public identifiers. This will +remove much of the conflict that arises from different packages +using the same identifier to hold different meanings. +\item Support for various tricks to help conserve \TeX's hash table +(maximum number of control words), registers (\verb|\count|, \verb|\skip|, +etc.)\ and other resources. +\end{itemize} + +\section{Conclusions} +There is currently international discussion within the \TeX\ +community -- under the title NTS (new typesetting system) -- of what +if anything should replace \TeX\ the program. The \verb|\noname| package +demonstrates that much more can be done with \TeX\ than is commonly +realized. In particular, it removes some (not all) of the +difficulties in programming \TeX. It is important to understand what +can and cannot be done with \TeX\ as it is, and how or why not, if +one is set on creating a successor. + +I began by posing the question, what should we teach \TeX? My +response is this. First of all we should teach \TeX\ how to read and +understand macros written in a well-designed high(er) level extension +or dialect of \TeX. It will then be much easier to write the many +tens of thousands of lines that make up \LaTeX\ 2.09 and 3, and +countless other macro packages across the world. + +If you are interested in \verb|\noname| and would like a demonstration +copy, please contact me. The price, for a site license, will be two +or three figures. For approved public domain developers, the price +will be zero. + +\end{article} |