cs: use print-as-expression
in default print handler
This commit is contained in:
parent
b45e3767da
commit
258fb8fafd
|
@ -13,8 +13,12 @@
|
|||
(format "~v" v))
|
||||
(define (to-pretty-string v)
|
||||
(pretty-format v))
|
||||
(define (to-string/not-expression v)
|
||||
(parameterize ([print-as-expression #f])
|
||||
(to-string v)))
|
||||
(test (regexp-replace* #rx"\n *" s " ") to-string v)
|
||||
(test s to-pretty-string v))])
|
||||
(test s to-pretty-string v)
|
||||
(test (format "~s" v) to-string/not-expression v))])
|
||||
(define-struct a (x y))
|
||||
(define-struct b (x y) #:transparent)
|
||||
(define-struct c (x y) #:prefab)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#lang racket/base
|
||||
(require "../common/check.rkt"
|
||||
"../port/parameter.rkt"
|
||||
"../print/parameter.rkt"
|
||||
"../port/output-port.rkt"
|
||||
"../port/string-port.rkt"
|
||||
"../string/convert.rkt"
|
||||
|
@ -34,7 +35,9 @@
|
|||
|
||||
(define (simple-format a)
|
||||
(cond
|
||||
[(boolean? a) (string-copy (if a "#t" "#f"))]
|
||||
[(boolean? a) (string-copy (if (print-boolean-long-form)
|
||||
(if a "#true" "#false")
|
||||
(if a "#t" "#f")))]
|
||||
[(number? a) (number->string a)]
|
||||
[(keyword? a) (string-append "#:" (keyword->string a))]
|
||||
[else #f]))
|
||||
|
|
|
@ -103,8 +103,9 @@
|
|||
|
||||
(define (install-do-global-print! param default-value)
|
||||
(set! do-global-print
|
||||
(lambda (who v o [quote-depth PRINT-MODE/UNQUOTED] [max-length #f])
|
||||
(lambda (who v o [quote-depth-in PRINT-MODE/UNQUOTED] [max-length #f])
|
||||
(define global-print (param))
|
||||
(define quote-depth (if (print-as-expression) quote-depth-in WRITE-MODE))
|
||||
(cond
|
||||
[(eq? global-print default-value)
|
||||
(do-print who v o quote-depth max-length)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user