Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!agate!priam.Berkeley.EDU!edward From: edward@priam.Berkeley.EDU (Edward Wang) Newsgroups: comp.text.tex Subject: Re: Why use TeX if ... Message-ID: <1991May14.045047.21106@agate.berkeley.edu> Date: 14 May 91 04:50:47 GMT References: <1991May10.211802.4344@csrd.uiuc.edu>> Sender: root@agate.berkeley.edu (Charlie Root) Organization: University of California, Berkeley Lines: 55 In article <1991May13.220314.17535@csrd.uiuc.edu> eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) writes: >As I pointed out in another msg five minutes ago, TeX processes >its input sequentially. There is no 'source code' that accepts >the 'input text' and processes it: there is only the >input text. Therefore macros are the only principle for >such a model of typesetting. I don't see immediately >how you would implement any system for typesetting that >is of a markup principle and that is not essentially >a macro language. I don't think so. Let me try this roundabout argument on you: On the surface, Tex's execution model is to transform input text into typeset output, and embedded in the text are macros that are expanded. However, some macros expand to nothing, but produce some side effect. Some of these are used to define other macros (\def). In the extreme cases (like latex.tex), the input is nothing but definitions. Here, the input is no longer data, but is clearly an executable program. So Tex can be thought of as an interpreter for a programming language. It executes the commands and treates the text as arguments to implicit commands. (In fact, Tex allows these commands to be explicit: \indent, \noindent, \par.) In this model, most commands have side effect. Some commands define other commands, some change global parameters, and some produce DVI output. I believe it's possible to redefine Tex this way and still allow it to accept exactly the same input. Given this, it's clearly possible to add true functions to Tex. Functions can't replace macros in Tex because they can't exactly duplicate the functionality, but I think it's possible to build an equally powerful system (with a different look) using only functions. Let me add a bit of concreteness to this discussion. Luigi Semenzato and I have designed an experimental typesetting language based on Lisp. It has a sublanguage for entering text, with an extensible syntax. The typesetting model is from boxes and glue (the output is Tex). The input, however, is based on Lisp functions that build trees that represent text. The syntax extension mechanism in the sublanguage is macro-like (character sequences are mapped into Lisp expressions), but the sublanguage is used only for text entry. Most of the programming is done in Lisp. The two languages coexist. Switching between them is simple and natural. We have a paper on our system in the July TUG meeting. To make the input look like a descriptive markup, the commands have to be designed carefully. For one thing, they must be mostly side-effect free. It's the same discipline that's needed to make Tex input a descriptive markup.