(require mzlib/pconvert) |
The mzlib/pconvert library defines routines for printing Scheme values as evaluable S-expressions. Racket’s default printing mode also prints values as expressions (in contrast to the Lisp and Scheme tradition of printing readable S-expressions), but mzlib/pconvert is more configurable and approximates expressions for a wider range of values. For example, procedures print using lambda instead of #<procedure>.
The print-convert procedure does not print values; rather, it converts a Scheme value into another Scheme value such that the new value pretty-writes as a Scheme expression that evaluates to the original value. For example, (pretty-write (print-convert `(9 ,(box 5) #(6 7)))) prints the literal expression (list 9 (box 5) (vector 6 7)) to the current output port.
To install print converting into the read-eval-print loop, require mzlib/pconvert and call the procedure install-converting-printer.
In addition to print-convert, this library provides print-convert, build-share, get-shared, and print-convert-expr. The last three are used to convert sub-expressions of a larger expression (potentially with shared structure).
See also prop:print-convert-constructor-name.
parameter
(abbreviate-cons-as-list abbreviate?) → void? abbreviate? : any/c
parameter
(booleans-as-true/false use-name?) → void? use-name? : any/c
parameter
(use-named/undefined-handler) → (any/c . -> . any/c)
(use-named/undefined-handler use-handler) → void? use-handler : (any/c . -> . any/c)
The initial value of the parameter is (lambda (x) #f).
parameter
(named/undefined-handler) → (any/c . -> . any/c)
(named/undefined-handler use-handler) → void? use-handler : (any/c . -> . any/c)
The initial value of the parameter is (lambda (x) #f).
parameter
(add-make-prefix-to-constructor add-prefix?) → void? add-prefix? : any/c
procedure
(build-share v) → ....
v : any/c
parameter
(constructor-style-printing use-constructors?) → void? use-constructors? : any/c
The constructor used for mutable pairs is mcons, unless print-mpair-curly-braces is set to #f, in which case cons and list are used. Similarly, when using quasiquote style and print-mpair-curly-braces is set to #f, mutable pair constructions are represented using quote, quasiquote, etc.
See also quasi-read-style-printing and prop:print-convert-constructor-name.
parameter
→
(any/c (any/c . -> . void?) (any/c . -> . void?) . -> . any) (current-build-share-hook hook) → void?
hook :
(any/c (any/c . -> . void?) (any/c . -> . void?) . -> . any)
A current-build-share-hook procedure usually works together with a current-print-convert-hook procedure.
parameter
→ (any/c . -> . (or/c symbol? false/c)) (current-build-share-name-hook hook) → void? hook : (any/c . -> . (or/c symbol? false/c))
parameter
(current-print-convert-hook) →
(any/c (any/c . -> . any/c) (any/c . -> . any/c) . -> . any/c) (current-print-convert-hook hook) → void?
hook :
(any/c (any/c . -> . any/c) (any/c . -> . any/c) . -> . any/c)
A current-print-convert-hook procedure usually works together with a current-build-share-hook procedure.
parameter
(current-read-eval-convert-print-prompt str) → void? str : string?
procedure
(get-shared share-info [cycles-only?])
→ (list-of (cons/c symbol? any/c)) share-info : .... cycles-only? : any/c = #f
The default value for cycles-only? is #f; if it is not #f, get-shared returns only information about cycles.
For example,
(get-shared (build-share (shared ([a (cons 1 b)] [b (cons 2 a)]) a)))
might return the list
'((-1- (cons 1 -2-)) (-2- (cons 2 -1-)))
procedure
procedure
(print-convert v [cycles-only?]) → any/c
v : any/c cycles-only? : any/c = (show-sharing)
procedure
(print-convert-expr share-info v unroll-once?) → any/c share-info : .... v : any/c unroll-once? : any/c
The unroll-once? argument is used if v is a shared value in share-info. In this case, if unroll-once? is #f, then the return value will be a shared-value identifier; otherwise, the returned value shows the internal structure of v (using shared value identifiers within v’s immediate structure as appropriate).
parameter
(quasi-read-style-printing on?) → void? on? : any/c
parameter
(show-sharing) → boolean?
(show-sharing show?) → void? show? : any/c
parameter
(whole/fractional-exact-numbers whole-frac?) → void? whole-frac? : any/c