\documentstyle[ltugboat]{article}

\let\tensl=\sl
\title{\WEB{} Adapted to \LaTeX{} --- a First Attempt}
\author{David Love}
\netaddress{d.love@daresbury.ac.uk}
\begin{document}
\maketitle
\noindent
Following Knuth's original Pascal/TeX{} \WEB{} system a number of
\WEB-like systems have been developed.  Mostly these use the same
plain \TeX{} formatting system and differ in the languages supported
(although Thimbleby's CWEB system uses Troff and there are non-\WEB{}
literate programming systems like Scheme\TeX{} and {\tt doc.sty} that
use \LaTeX)\footnote{For a \WEB{} bibliography, see Lisa M. C. Smith
and Mansur Samadzadeh, {\sl SIGPLAN Notices\/} {\bf 26} (1991) 14}\@.
There are two advantages to using \LaTeX{} rather than plain \TeX{}
for formatting:
\begin{itemize}
\item greater accessibility for many (familiarity and ease of use)
which may encourage more people to use it;
\item the availability of extra intrinsic \LaTeX{} facilities and
especially style options.  These might, for instance, support setting
your formal specification material as well as the code refined from
it, and in non-CM fonts.
\end{itemize}
This note describes a first attempt at integrating \LaTeX{} with
\WEB\ (actually Ramsey's Spider system for
`language-independent' \WEB s\footnote{Sometimes Spider doesn't do the
whole job for you: non-Algol-like languages may need the lexing
routines hacking.  This gives the complication of
amalgamating the basic \WEAVE{} change file for \LaTeX{} formatting
with changes for the lexical routines etc.}).

I have made minimal changes necessary for Spidery \WEB s to work with
\LaTeX\@.  These take the form of change files for the base {\tt
weave.web}, {\tt tangle.web} and {\tt spider.web} (which generates the
language-dependent parts), conversion of the {\tt webkernel.tex} macro
file to a \LaTeX{} sub-style and trivial updates to the make files.  A
trivial change to the {\tt c.spider} file that describes the
prettyprinting grammar for C was also necessary.  The result of
merging the change files with the original webs would be a {\tt
weave.web} that can be built for use with either plain \TeX\ or
\LaTeX\ using a makefile flag and a {\tt spider.web} that produces a
{\tt spider.awk} with a run-time switch to determine the formatter.
(\WEAVE\ cannot change the formatter assumed at run time, although it
would not be difficult to make it do so.)  \WEB\ files can be woven
with either a plain or \LaTeX\ \WEAVE\ if they avoid using
incompatible macros or define them appropriately in limbo
according to whether the \LaTeX\ macros are present.

The changes to {\tt spider.web} are minor; changes to {\tt weave.web}
and the macros are more extensive.  Many of the original \WEB{} macros
clash with \LaTeX{} names or conventions and have been changed
appropriately, but only where necessary.  The formatting style is
essentially unchanged apart from the use of the \LaTeX\ page headers
and contents list.  {\tt web.sty} is documented with {\tt doc.sty}
since it is a pity not to use literate techniques to build literate
programming tools---the bulk of the work!  There are some remaining
infelicities, such as floats being disrupted by the way the sectioning
code avoids page breaks and a lot of messiness due to the assumptions
of existing Spider descriptions.

This hack could be developed in other directions, for instance:
\begin{itemize}
\item proper parameterisation of the formatting commands, perhaps
modelled after {\tt makeindex};
\item adapting the formatting macros more to the \LaTeX{} style;
\item inclusion of a proper multi-level sectioning scheme.  I think
the extra structure would be helpful in large webs, but implementing
it would require considerable attention to the guts of \TANGLE{} and
\WEAVE\@.  (It affects \TANGLE{} through the comments it writes in the
code);
\item replacing the index processing with {\tt makeindex}.
\end{itemize}

The changes should be available from the Aston archive as {\tt
[.web.spiderweb]latexmods.shar}. 

\makesignature
