johnsson@cs.glasgow.ac.uk (Dr. T. Johnsson) (06/07/90)
How would one design macros or environments to prettyprint computer programs? The tricky bit (presumably!) would be to recognize keywords and other special symbols of a programming language, and output them in \bf or as math, instead of some default treatment. For instance, \beginpascal if iffy > 42 then msg("ugly!"); \endpascal would produce something like {\bf if} {\it iffy\/} $>$ 42 {\bf then} {\it msg\/}$($``{\tt ugly!}''$)$$;$ I would also like to be able to treat the character backslash as a symbol; for instance, \beginlambda \x.\y.(y (\z.z) x) \endlambda would produce something like $\lambda$x.$\lambda$y.$($y $($$\lambda$z.z$)$ x$)$ Thanks! Thomas Johnsson (cs.glasgow.ac.uk)
lgy@phys.washington.edu (Laurence G. Yaffe) (06/08/90)
johnsson@cs.glasgow.ac.uk (Dr. T. Johnsson) writes: >How would one design macros or environments to prettyprint computer >programs? The tricky bit (presumably!) would be to recognize keywords >and other special symbols of a programming language, and output them >in \bf or as math, instead of some default treatment. For instance, >Thomas Johnsson (cs.glasgow.ac.uk) I have never understood why this printing style deserves to be called "pretty". It places excessive emphasis on the language keywords; they should never be the focus of attention for someone trying to understand the program. In prose, one would never print punctuation marks like commas or periods in a way which gave them greater visual impact than ordinary letters - why do it with programs? -- -------------------------------------------------------------------------- Laurence G. Yaffe Internet: lgy@newton.phys.washington.edu University of Washington Bitnet: yaffe@uwaphast.bitnet