Subject: pretty printer

From: Joachim Schrod <[email-masked]>
Date: Wed, 26 Jan 1994 14:01:41 +0100 (MEZ)

Hi,

CLtL2, Chapter 27, describes a prettyprinting facility.

Anybody knows a freely distributable implementation that could be used
with CLISP?  It may not be plug&play, we're not afraid of some
programming work.

How about XP, is it available by anonymous ftp?
Or is one in CMUCL that might be used?

Thanks in advance for any answers,

	Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Joachim Schrod			Email: [email-masked]
Computer Science Department
Technical University of Darmstadt, Germany

---

From: [email-masked] (Don Cohen)
Date: Thu, 27 Jan 94 09:34:23 -0800

I'd like to mention that I sent a pretty printer to Bruno and Marcus.
(I presume they're in the archives, but I'll be happy to send another
copy to anyone who wants it.)  It is first of all small and simple
which makes it a good starting point if you want to alter it.  It is
programmable in the usual sense - that you get to say how to treat
lists that start with a given symbol.  It was meant for code, and
solves what I consider annoying problems with other pp's.  All this
is documented in the source.
Now some replies:
  CONTRA XP:
  If a pretty-print layout becomes mandatory for every macro, then writing
  macros becomes combersome.
I don't think that this is a requirement for any PP
  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.
The program that prints LET is allowed to look at what's inside.  If the 
form doesn't LOOK like a let form it can print it the default way.  If you
plan to PP data with lists starting with LET then maybe you should instruct
the PP how to recognize them as data.  This could include context, e.g.,
the form that starts the "data" could bind a special variable that would be
read by the LET PP macro.
  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.
I disagree that it makes anything easier - I think it's a lot uglier.
You can generally tell where a nesting level ends by looking down in the
same column.
  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.
This is the main problem (along with the desire for print macros) that
caused me to write the one I sent you.  How does the CLISP PP solve the
problem?

  While the *PRINT-CIRCLE* ...
  When *PRINT-LENGTH* or *PRINT-LEVEL* ...
These are not addressed in my PP.