[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pretty printer
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: Re: pretty printer
- From: haible (Bruno Haible)
- Date: Thu, 27 Jan 94 16:43:06 +0100
Joachim Schrod <schrod@iti.informatik.th-darmstadt.de> says:
> CLtL2, Chapter 27, describes a prettyprinting facility.
CLtL2, Chapter 27, describes the XP "pretty" printer.
> How about XP, is it available by anonymous ftp?
> Or is one in CMUCL that might be used?
XP is used in CMU CL and WCL.
> It may not be plug&play, we're not afraid of some programming work.
But decide first what you want. I will try a comparison between CLISP's
pretty printer and XP as specified in CLtL2 and implemented in xp.lisp.
PRO XP:
XP is extensible. A programmer/user can specify how his DO, LET,
MULTIPLE-VALUE-BIND etc. forms are printed.
CONTRA XP:
If a pretty-print layout becomes mandatory for every macro, then writing
macros becomes combersome.
CONTRA XP:
It looks ugly when a list containing data which happens to look like
(LET ...) is printed as if it were a Lisp form. There is no way by which
the system could decide whether some object is data or program.
CONTRA CLISP:
CLISP indents by 1 for every nesting level. XP indents by 2, which makes
up for better readability. (This could be easily fixed in io.d.)
PRO CLISP:
Closing parentheses are output just below their corresponding opening
parenthesis, if *PRINT-RPARS* is T. This makes it much easier for a human
reader to find out where a certain nesting level ends.
CONTRA XP, PRO CLISP:
Heavily nested lists and structures tend to reach the right margin very
quickly in XP. This fact is even recognized by the existence of the variable
*PRINT-MISER-WIDTH*. And it is not handled satisfactorily in XP: it
produces lots of lines with much space on the left and only one token
at the right margin, often exceeding the line length.
PRO CLISP:
While the *PRINT-CIRCLE* mechanism used in XP uses a large hash table
which holds every subobject of the object to be printed, CLISP's
*PRINT-CIRCLE* handling builds up a (usually much smaller) hash table
which holds only those subobjects which occur more than once.
(Detection of these subobjects is done by a low-level subroutine.)
PRO XP:
When *PRINT-LENGTH* or *PRINT-LEVEL* is non-NIL, CLISP may print #n=
with no #n# references: #1=(A ...)
XP does this better because its decision whether to print #n= comes
last.
Bruno Haible
haible@ma2s2.mathematik.uni-karlsruhe.de