[plt-scheme] Re: Problems with pretty-print-print-line

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Tue Jan 8 12:58:01 EST 2008

On Tue, Jan 08, 2008 at 12:41:55PM -0500, Richard Cobbe wrote:
> I'm having some difficulty making the pretty-print library do what I want
> it to.

> that is, an extra newline in front of the pretty-printed list, and an extra
> prefix at the end.  I figured I could fix these problems by using the
> following parameter setting:
>
>     (pretty-print-print-line
>      (lambda (line-no out-port len num-cols)
>        (cond
>          [(zero? line-no)       ;; for first line
>           (fprintf out-port "- ")
>           2]
>          [(not line-no)         ;; for last line
>           (fprintf out-port "~n")
>           0]
>          [else                  ;; all other lines
>           (fprintf out-port "~n- ")
>           2])))

Never mind -- I forgot that #f isn't in the domain of `zero?' (or `=',
either, which is what I actually used).  Switching the first two cond
clauses works fine.

I am going to submit a bug on the divergence, though -- failing with an
exception is clearly the preferable behavior there.  If nothing else, I
would have found the bug without cluttering up the list.

Richard


Posted on the users mailing list.