Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!cass.ma02.bull.com!mips2!bull.bull.fr!corton!mcsun!ukc!ox-prg!culhua!Damian.Cugley From: Damian.Cugley@prg.ox.ac.uk (Damian Cugley) Newsgroups: comp.text.tex Subject: Re: Why use TeX if ... Message-ID: Date: 13 May 91 14:13:47 GMT References: <1991May9.164341.14084@csrd.uiuc.edu> <1991May9.204113.17636@beaver.cs.washington.edu> <1991May10.065219.23433@agate.berkeley.edu> <1991May10.211802.4344@csrd.uiuc.edu> Sender: news@prg.ox.ac.uk Organization: Computing Laboratory, Oxford University, UK Lines: 70 In-reply-to: eijkhout@s41.csrd.uiuc.edu's message of 10 May 91 21:18:02 GMT > From: Victor Eijkhout > Message-Id: <1991May10.211802.4344@csrd.uiuc.edu> > >In article <1991May9.204113.17636@beaver.cs.washington.edu> > > pauld@stowe.cs.washington.edu (Paul Barton-Davis) writes: > >>The hacking problem is primarily caused by the fact that the TeX > >>extension language was designed (apparently) as a macro replacement > >>language. If TeX has a "normal" or "proper" programming language, then > >>it would a lot easier to extend, without getting used to its > >>arcane grammar. > What do you mean 'arcane grammar'? TeX, like that other > symbolic language Lisp, has no syntax to speak of. He really meant arcane *semantics* -- what is expanded when and why and how to change this sequence and why. One of the problems with TeX is precisely that it does lack syntax -- and hence structure. Lisp has syntax which has been reduced to the bare minimum: structure with no "frou-frou". Unlike TeX, which has some "frou-frou" but no structure! > Control sequences are trivially recognised, macro argument > absorbtion uses only the simplest type of pattern matching. > Some trivial facts about braces, and there you have > the whole of TeX. The other 475 pages of the TeXbook are just padding?!? :-) > But I do agree that the language is arcane. This is a consequence > of the fact that TeX is not really processed by a single > interpreter, but rather by three or four processor[s]. > 1/ The input processor; -- which Knuth calls the eyes; > 2/ The expansion processor, and -- the mouth; > 3/ The execution processor. -- the stomach. In other words: TeX is a macro language -- all macro languages are like this. (All computer languages are conceptually translated/interpreted in several distinct phases, if it comes to that.) The eyes and stomach are not what makes TeX arcane; it is the fact that TeX's only abstraction mechanism is textual substitution (macro replacement). Macro languages are a very easy way to implement a moderately powerful extension language. You just supply primitives operations on whatever datatype the problem involves (e.g., boxes and glue in TeX's case; paths and pictures in METAFONT's case; Pascal instructions in the case of WEB) and slap a macro-replacement system on top. Voila -- a programmable typesetter or font creator or whatever. The problems is that macro languages are just about the worst thing to have when trying to program anything non-trivial. The most frustrating bugs to track down in TeX code are caused by macros that expand at the wrong time, or trivial errors in what they expand to which are only spotted when primitive commands go wrong. Having TeX as a non-macro-based language does not imply that it must resemble C or Pascal or Lisp (although if TeX *programs* resembled (say) Lisp or Pascal rather than just a mess of backslashes it would be no bad thing). ---- Damian Cugley -------------------------------- pdc@prg.ox.ac.uk --- Computing Laboratory, 11 Keble Rd, Oxford OX1 3QD Great Britain ------------------------------------------------------------------------ malvern-request@prg.ox.ac.uk "share and enjoy"