[Openmcl-devel] pretty printing

Philippe Sismondi psismondi at arqux.com
Mon Nov 16 18:42:52 PST 2009


On 2009-11-16, at 9:11 PM, Joshua TAYLOR wrote:

> On Mon, Nov 16, 2009 at 8:51 PM, Philippe Sismondi <psismondi at arqux.com 
> > wrote:
>> Should I expect ccl to pretty-print when *print-pretty* is set to T?
>> I am new to CL, so what I did was to type in the example in  
>> Hyperspec:
>> (let ((*print-pretty* t))
>> (progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil))
>>>> (LET ((A 1)
>>>> (B 2)
>>>> (C 3))
>>>> (+ A B C))
>> => NIL
>> […]
>> - Philippe -
>
> The particular behavior of the pretty printer is dependent on a number
> of things, one of which is the value of the variable
> *PRINT-RIGHT-MARGIN*.  For instance, doing as you did above, I also
> see the list printed on a single line.  But if *PRINT-RIGHT-MARGIN* is
> bound to a smaller value, I think you'll see output more like what you
> were expecting.  E.g.,
>
> ? (let ((*print-pretty* t)
>        (*print-right-margin* 15))
>    (progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil))
> (LET
> ((A 1)
>  (B 2)
>  (C 3))
> (+ A B C))
> NIL
>
> Another thing to check is whether "bigger" lists will automatically
> print with some of the indentation you'd expect.  E.g.,
>
> ? (let ((*print-pretty* t))
>    (progn (write '(let ((a (+ 1 1 1 1 1 1 1)) (b (+ 2 2 2 2 2 2 2))
> (c (+ 3 3 3 3 3 3 3 3 3 3)) (d (+ 4 4 4 4 4 4 4 4 4))) (+ a b c d)))
> nil))
> (LET ((A (+ 1 1 1 1 1 1 1))
>      (B (+ 2 2 2 2 2 2 2))
>      (C (+ 3 3 3 3 3 3 3 3 3 3))
>      (D (+ 4 4 4 4 4 4 4 4 4)))
>  (+ A B C D))
>
> //JT



Thanks for responding.

The value *print-right-margin* does make a difference when I try the  
example. Also, long lists are handled differently, as you suggest.

However, this seems bizarre to me. Maybe my expectations are off. I  
was hoping for lisp pretty-print behaviour similar to what the  
'indent' utility does for my C source code. The indent utility indents  
without having the right margin set.

Is there not some more or less standard way to indent CL source? Why  
would lisp pretty-printing not do that by default?

- Phil -


More information about the Openmcl-devel mailing list