[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about pprint, *print-pretty*



    Date: Sun 31 Aug 86 14:39:44-MDT
    From: SANDRA <LOOSEMORE@UTAH-20.ARPA>

    In Common Lisp, both print and pprint are defined to print out a newline
    *before* the form rather than after.  This is backwards from PSL, where
    the prettyprinter indents things relative to the "current" character
    position on the output stream, and prints a newline afterwards.  Is there
    a portable way I can get the same kind of relative indentation in Common
    Lisp?  Exactly what turning on *print-pretty* does is left rather vague --
    the manual just says the printer should insert more whitespace.  Is there
    some overwhelming reason why these functions were defined "backwards" in
    the first place that I've missed?

I don't know if this is an overwhelming reason, but PRINT has always printed
the newline first, all the way back to Lisp 1.5 (check the blue and white Lisp 1.5
manual).  I think it's intentional that the definition of what it means to
print prettily is left rather vague, since different implementations have
different ideas about what looks pretty and about how effort they are willing
to expend to make something look pretty.

Surely binding *PRINT-PRETTY* to T is not supposed to turn PRIN1 into
PPRINT.  In other words, PRIN1 with *PRINT-PRETTY* = T should not print
a leading newline, should indent things relative to the current
character position on the output stream, and should not print a trailing
newline.  Next time the manual should include definitions of all of these
functions in terms of WRITE, instead of only defining half of them!