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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jan 8 12:48:06 EST 2008

At Tue, 8 Jan 2008 12:41:55 -0500, Richard Cobbe wrote:
>     (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])))

The `zero?' function requires its argument to be a number. So if
`line-no' is #f, then there will be an exception.

My guess is that an exception is raised, and the construction of the
exception message invokes the pretty printer, which raises an
exception...

Does swapping the first two `cond' clauses fix the problem?

Matthew



Posted on the users mailing list.