diff --git a/collects/mzlib/pconvert.rkt b/collects/mzlib/pconvert.rkt index 5678befecd..f68a1d2b79 100644 --- a/collects/mzlib/pconvert.rkt +++ b/collects/mzlib/pconvert.rkt @@ -576,6 +576,7 @@ (current-print (lambda (v) (unless (void? v) (print (print-convert v)))))) + (print-as-expression #f) (current-prompt-read (lambda () (display (current-read-eval-convert-print-prompt)) (read-syntax 'STDIN)))))) diff --git a/collects/mzlib/scribblings/pconvert.scrbl b/collects/mzlib/scribblings/pconvert.scrbl index 10cd4bfecc..d3b51ab9e2 100644 --- a/collects/mzlib/scribblings/pconvert.scrbl +++ b/collects/mzlib/scribblings/pconvert.scrbl @@ -7,15 +7,21 @@ @mzlib[#:mode title pconvert] The @schememodname[mzlib/pconvert] library defines routines for -printing Scheme values as @scheme[eval]uable S-expressions, rather -than @scheme[read]able S-expressions. +printing Scheme values as @scheme[eval]uable S-expressions. Racket's +default printing mode also prints values as expressions (in contrast +to the Lisp and Scheme tradition of printing @scheme[read]able +S-expressions), but @schememodname[mzlib/pconvert] is more +configurable and approximates expressions for a wider range of +values. For example, procedures print using @schemeresultfont{lambda} +instead of @schemeresultfont{#}. The @scheme[print-convert] procedure does not print values; rather, it converts a Scheme value into another Scheme value such that the new -value pretty-prints as a Scheme expression that evaluates to the -original value. For example, @scheme[(pretty-print (print-convert `(9 -,(box 5) #(6 7))))] prints the literal expression @schemeresult[(list -9 (box 5) (vector 6 7))] to the current output port. +value @racket[pretty-write]s as a Scheme expression that evaluates to +the original value. For example, @scheme[(pretty-write (print-convert +`(9 ,(box 5) #(6 7))))] prints the literal expression +@schemeresult[(list 9 (box 5) (vector 6 7))] to the current output +port. To install print converting into the read-eval-print loop, require @scheme[mzlib/pconvert] and call the procedure @@ -182,8 +188,10 @@ might return the list @defproc[(install-converting-printer) void?]{ Sets the current print handler to print values using -@scheme[print-convert]. The current read handler is also set to use -the prompt returned by +@scheme[print-convert] and sets @racket[print-as-expression] to +@racket[#f] (since the conversion of a value is meant to be printed in +@racket[read]able form rather than @racket[eval]uable form). The +current read handler is also set to use the prompt returned by @scheme[current-read-eval-convert-print-prompt].}