Syntactic Sugar

Syntactic Sugar

Syntactic Sugar Kees van der Laan Hunzeweg 57, 9893PB, Garnwerd, The Netherlands, 05941-1525 Internet: cgleri scl. rug. nl Abstract A plea is made for being honest with TEX and not imposing alien structures upon it, other than via compatible extensions, or via (non-TEX)user interfaces to suit the publisher, the author, or the typist. This will facilitate the process of producing (complex) publications effectively, and typographcally of hgh-quality. Introduction and the simplicity of the (generic) macros should be warranted too. TEX is a formatter and also a programming language. It is not the aim of this paper to revitalize a pro- TEX is unlike traditional hgh-level programming lan- gramming languages notation war, but to stimulate guages. It is still powerful, in a class of its own, awareness and exchange ideas. unusual, and unfamiliar. First, 1'11 glance at the big collections, and after Because TEX is different, macro writers propose that I'll dive into the details of macros from various harnessing it into a more farmliar system, by impos- sources. ing syntaxes borrowed from various successful high- level programming languages. In doing so, injustice In the Large to TEX'S nature might result, and users might be- come intimidated, because of the difficult-at least Let me first look roughly at the big collections, and unusual-encoding used to acheve the aim. The refer for more details to papers on the issue. more so when functional equivalents are already In my opinion the math mark-up in Spivak's there, although perhaps hdden, and not tagged by AM-TEX is syntactic sugar. It claims to be essen- familiar names. Ths is demonstrated with examples tially simpler than plain's math mark-up, which it about the loop, the switch, array addressing, op- is not. It is just different and does not provide tional and keyword parameters, and mouth versus more facilities than plain. A proof? All the ex- stomach processing. amples provided in "The Joy of TEX" can be format- Furthermore, TEX encodings are sometimes pe- ted equally withn plain. In L%S-TEX the table part culiar, different from the familiar algorithms, pos- and the commutative diagrams are substantial ex- sibly because macro writers are captivated by the tensions of plain, next to the general symbolic refer- mouth processing capabilities of TEX. Users who ence scheme. For more details see my book review don't care so much about TEX'S programming power of Spivak's CEuvre. but who are attracted by the typesetting quality I consider amsppt . sty and the llke an adapta- whch can be obtained with TEX as formatter, can tion by a publisher of manrnac for production, with be led astray when, while searchng for a particu- value added, if not for the user's guides and the lar functionality, they stumble upon unusual encod- provided support. These latter things can't be over- ings. They might conclude that TEX is too difficult, estimated for Ben Lee User1 in my opinion. For more too error-prone and more things like that and flee detail see my AMS BLUes. towards Wordwhatever, or embrace Desk Top Pub- Furthermore, I consider lQXas syntactic sugar, lishing systems. especially the math part. LATEX 2.x is even more dan- The way out is education, next to the provi- gerous because it claims to be perfect, which it is sion of compatible, well-documented and supported not. If I compare the mark-up in the spirit of The user interfaces, whch don't act llke syntactic sugar, T~Xbookwith my mark-up obtained via LATEX, then by neglecting or hding the already avdable func- the latter is much more verbose and has not added tional equivalents. Neither the publication of encod- much. The extras llke the picture environment, sym- ings nor the provision of encodings via file servers bolic and cross-referencing, and the bibliography or archves - although a nice supporting feature for ' From The THbook fame, I like the nickname the T~Xies-is enough. The quality, compatibility BLU. TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting Syntactic Sugar environment, can be added easily by independent Why another loop? Kabelschacht (1987) and Spivak tools in a manrnac-llke basis, when neededm2Multi- (1989, 1991) favour a loop whch allows the use of column issues have in general their difficulties - \el ~e.~I have some objections to Kabelschacht's more llkely buses-and-weirdness effects will occur; claim that hsloop is a generalization of plain's loop. see Richard Southall's contribution about theseis- First, it is not a generalization, just a clever, sues at this conference - but if one is willing to ad- but variant, implementation of the loop flow chart. apt proofs by hand now and then, it can be added Second, it is not compatible with plain's loop. His because the functionality is available as a separate exit path is via the \then branch (or via any of the tool, nowadays. \or-s, when \ifcase is used), and not via the \else If only manmac and Knuth's other example branch. formats had been appropriately documented The reason I can thnk of for introducing an- in (additional) user's guides, then the (LA)TEX other loop, while the most general form has been world would have looked much different implemented already, is the existence of commands from what it is today. like \ifvoi d, and \ifeof, and the absence of their negatives \ifnonvoi d and \ifnoneof, respectively. In the Small In those cases we like to continue the loop via the \else branch. For the latter case this means In the sequel I'll descend into detail and discuss: to continue the loop when the file is not ended. loops, switches, array addressing, optional and This can be attained via modifying the loop, of keyword parameters, mouth processing, sorting and course, but I consider it simpler to use a \newif lexicographc comparison. parameter, better known as 'boolean' or 'logical' in Loops. Knuth's loop, (The THbook, p. 219), imple- other programming languages. With the \newi f ments the general flow ~arameter,~\ifneof, the loop test for an end of file-functionally l\ifeof-can be obtained via \ifeof\neoffal se\ei se\neoftrue\fi \ifneof pretst For an example of use, see the Sort It Out subsection. Related to the above encoding of the logical 1,are the encodings of the logical and, A, and or, v, via Functional code TEX encoding -\if. \if. .\notfa1 se\el se posttst \nottrue\fi\i fnot \if. ~\if . \andtrue\i f. .\if . \el se\andfal se with (pseudo) syntax \el se\andfalse\fi \fi \ifand \loop(pretst)\i f (posttst)\repeat. \if ...v\if ... \ortrue Special cases result when either (pretst) or \if...\else\if.. .\else (posttst) is empty. The former is equivalent to, for I \orfalse\fi\fi \ifor example, PASCAL'S while .do , and the latter to . with the \newi f-s: \ifnot, \ifand, and \ifor. repeat...until. With ths awareness, I consider the Nesting of loops. Pittman (1988) argued that there variants as proposed by, for example, Pittman (1988) is a need for other loop encodings. and Spivak (1991) as syntactic sugar. If \ifcase. is used, then we have for 'Recently, I encountered an application that (posttst) several parallel paths, of whch one - de- required a set of nested loops and local- termined dynamically - will be traversed. Provide only assignments and definitions. TEX'S and choose your path! What do you mean by tra- \loop. .\repeat construction proved to be versing the \el se-path? inadequate because of the requirement that the inner loop be grouped.' With respect to the mark-up of the list of ref- erences it is such a waste that every author should Their loops are equivalent to the general form supply the full mark-up. Why not just supply ref- of the loop with the execution of an extra part after erences to the database of pre-formatted entries, in the loop. possession of and maintained by the editors? Be aware that the implementation of \newi f does not allow for \global. TUGboat, Volume 14 (1993),No. 3 -Proceedings of the 1993 Annual Meeting Kees van der Laan If we take his (multiplication) table-I like to classify ted loops. One can apply ths to other deterministic these as deterministic tables, because the data as math tables - trigonometric tables for example - such are not typed in-to be representative, then be- but then we need more advanced arithmetic facil- low a variant encoding is given, which does not need ities in TEX (or inputting the data calculated by other Pittman's double looping. The table is typograph- tools), not to mention the appropriate mapping of ically a trifle, but it is all about how the determin- tables which extend the page boundaries. istic data are encoded. My approach is to consider it For a more complete encoding see my Table Di- primanly as a table, which it is after all. Withn the versions (van der Laan, 1992~).The idea is that rules table the rows and columns are generated, via recur- and a frame be commanded via \rul ed, respectively sion, and not via the \loop. Furthermore, I prefer \framed. The header via an appropriate definition to treat rules, a frame, a header and row stubs as of \header, x, the indication that we deal with a separate items to be added to the table proper, (van multiplication table, in \first, and the row stubs der Laan, 1992~).The creation of local quantities is via definition of the row stub list.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us