diff --git a/collects/mzlib/pconvert-prop.ss b/collects/mzlib/pconvert-prop.ss new file mode 100644 index 0000000000..461d72335c --- /dev/null +++ b/collects/mzlib/pconvert-prop.ss @@ -0,0 +1,21 @@ + +(module pconvert-prop mzscheme + + (provide prop:print-convert-constructor-name + print-convert-named-constructor? + print-convert-constructor-name) + + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; property recognized by print convert to set a value's constructor name: + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + (define-values (prop:print-convert-constructor-name + print-convert-named-constructor? + print-convert-constructor-name) + (make-struct-type-property 'print-convert-constructor-name + (lambda (s info) + (unless (symbol? s) + (raise-type-error '|prop:print-convert-constructor-name guard| + "symbol" + s)) + s)))) diff --git a/collects/mzlib/pconvert.ss b/collects/mzlib/pconvert.ss index 83fcdd1f56..e47a35d10f 100644 --- a/collects/mzlib/pconvert.ss +++ b/collects/mzlib/pconvert.ss @@ -2,7 +2,9 @@ (module pconvert mzscheme (require (prefix s: "string.ss") - (prefix f: "list.ss")) + (prefix f: "list.ss") + "etc.ss" + "pconvert-prop.ss") (require "class.ss") (require "unit.ss") @@ -413,13 +415,18 @@ ;; this case must be next to last, so that all of the ;; things with object-name's fall into the cases above first - [(object-name expr) - (let* ([name (object-name expr)] - [str-name (if (string? name) - name - (symbol->string name))] - [uniq (box #f)]) - `(,(string->symbol (string-append "make-" str-name)) + [(or (print-convert-named-constructor? expr) + (object-name expr)) + (let ([constructor + (if (print-convert-named-constructor? expr) + (print-convert-constructor-name expr) + (let* ([name (object-name expr)] + [str-name (if (string? name) + name + (symbol->string name))]) + (string->symbol (string-append "make-" str-name))))] + [uniq (begin-lifted (box #f))]) + `(,constructor ,@(map (lambda (x) (if (eq? uniq x) '...