diff --git a/collects/mzlib/class.ss b/collects/mzlib/class.ss index f703344..487101b 100644 --- a/collects/mzlib/class.ss +++ b/collects/mzlib/class.ss @@ -1,5 +1,5 @@ (module class mzscheme - + ;; All of the implementation is actually in private/class-internal.ss, ;; which provides extra (private) functionality to contract.ss. (require "private/class-internal.ss") @@ -7,7 +7,8 @@ (provide class class* class? - interface interface? + mixin + interface interface? object% object? object=? new make-object instantiate diff --git a/collects/mzlib/contract.ss b/collects/mzlib/contract.ss index 1d73517..6bcb8d5 100644 --- a/collects/mzlib/contract.ss +++ b/collects/mzlib/contract.ss @@ -678,7 +678,8 @@ add struct contracts for immutable structs? (string-append one-line " ") (let ([sp (open-output-string)]) (newline sp) - (parameterize ([pretty-print-print-line print-contract-liner]) + (parameterize ([pretty-print-print-line print-contract-liner] + [pretty-print-columns 50]) (pretty-print contract-sexp sp)) (get-output-string sp))))] [specific-blame diff --git a/collects/mzlib/etc.ss b/collects/mzlib/etc.ss index 69e74d7..80ae0cd 100644 --- a/collects/mzlib/etc.ss +++ b/collects/mzlib/etc.ss @@ -1,14 +1,18 @@ (module etc mzscheme + (require "spidey.ss" (lib "plthome.ss" "setup")) + (require-for-syntax (lib "kerncase.ss" "syntax") (lib "stx.ss" "syntax") (lib "name.ss" "syntax") (lib "context.ss" "syntax") - (lib "plthome.ss" "setup") - "private/stxset.ss") + (lib "plthome.ss" "setup") + "list.ss" + "private/stxset.ss") + (provide true false boolean=? symbol=? identity diff --git a/collects/mzlib/struct.ss b/collects/mzlib/struct.ss index 5c45336..a2a8fc5 100644 --- a/collects/mzlib/struct.ss +++ b/collects/mzlib/struct.ss @@ -1,11 +1,11 @@ -;; by Jacob Matthews +;; by Jacob Matthews (and others) (module struct mzscheme - (provide copy-struct) - + (provide copy-struct make-->vector) (require-for-syntax (lib "struct.ss" "syntax") - (lib "stx.ss" "syntax")) + "list.ss" + (lib "stx.ss" "syntax")) ;; copy-struct expands to `do-copy-struct' to delay the expansion ;; in an internal-definition context. (The `begin0' wrapper @@ -70,6 +70,23 @@ #,@(map (lambda (field) (or (new-binding-for field) #`(#,field the-struct))) (reverse accessors))) - (raise-type-error '_ #,(format "struct:~a" (syntax-object->datum #'info)) the-struct))))))]))]))) - - \ No newline at end of file + (raise-type-error '_ #,(format "struct:~a" (syntax-object->datum #'info)) the-struct))))))]))])) + + + (define-syntax (make-->vector stx) + (syntax-case stx () + [(_ name) ; a struct type name + (identifier? (syntax name)) + (let ([info (syntax-local-value (syntax name))]) + (if (struct-declaration-info? info) + (with-syntax ([(accessor ...) + (reverse + (filter identifier? (list-ref info 3)))]) + (syntax + (λ (s) + (vector (accessor s) ...)))) + (raise-syntax-error + #f + "not a declared structure type name" + stx + (syntax name))))])))