Re: pretty printing on LWL5.0.2
> >>>>> On Wed, 12 Sep 2007 16:18:50 -0400, Taylor, Joshua said:
> >
> > Hello all,
> >
> > I've got LWL 5.0.2 here on a IBM Thinkpad T22 running Ubuntu Feisty
> > Fawn. Here's the function in question:
> >
> > (defun do-pprint-test ()
> > (let ((stream *standard-output*))
> > (pprint-logical-block (stream () :prefix "(" :suffix ")")
> > (dotimes (i 10)
> > (write '(1 2 3 4 5 6 7 8 9 10) :stream stream)
> > (unless (eql 9 i)
> > (write-char #\space stream)
> > (pprint-newline :mandatory stream))))))
> >
> > I've got SBCL on the same machine, and when I run this function under
> > it, I get the following output:
> >
> > CL-USER> (do-pprint-test)
> > ((1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10))
> >
> > Under Lispworks, I get this:
> >
> > CL-USER 2 > (do-pprint-test)
> > ((1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10) (1 2 3 4 5 6 7 8 9 10)
> > (1 2 3 4 5 6 7 8 9 10))
> >
> > (in case Gmail wraps that, it's all on one line.)
> >
> > Working with the pretty printer, I was starting to think that maybe
> > *print-right-margin* or other things than influence the printer might
> > have been set up strangely under SLIME, but these two outputs are SBCL
> > and LispWorks run from the command line in an xterm. It's my
> > understanding that
> >
> > (pprint-newline :mandatory stream)
> >
> > should force a newline on stream.
> >
> > Is LWL doing something strange with the pretty printer, or have I (yet
> > again :) ) missed something in how the language works?
On 9/13/07, Martin Simmons <martin@lispworks.com> wrote:
>
> I think the problem is that you have *print-pretty* bound to nil. We changed
> pprint-newline in LispWorks 5.0 to match this paragraph in the CL spec:
>
> "If stream is a pretty printing stream and the value of *print-pretty* is
> true, a line break is inserted in the output when the appropriate condition
> below is satisfied; otherwise, pprint-newline has no effect."
>
Ah, I'd thought pprint-logical-block binds *print-pretty* to t, but
under "Notes" of pprint-logical-block, I see: "One reason for using
the pprint-logical-block macro when the value of *print-pretty* is
nil..." which makes it clear that it doesnt.
But, it makes some pretty printing functions I've been writing more
general which is good.
It's good to see LW and my brain aligned more with the spec. I'll be
sure to bind *print-pretty*.
Thanks for the quick reply!
--
=====================
Joshua Taylor
tayloj@rpi.edu
"A lot of good things went down one time,
back in the goodle days."
John Hartford