use define-record-writer to set custom writer to <array> type

This commit is contained in:
Yuichi Nishiwaki 2014-08-07 11:52:00 +09:00
parent 75138db4db
commit fff22f253f
1 changed files with 10 additions and 12 deletions

View File

@ -89,7 +89,7 @@
(define (array-for-each proc ary) (define (array-for-each proc ary)
(for-each proc (array->list ary))) (for-each proc (array->list ary)))
(define (print-array array) (define-record-writer (<array> array)
(call-with-port (open-output-string) (call-with-port (open-output-string)
(lambda (port) (lambda (port)
(display "#.(array" port) (display "#.(array" port)
@ -101,8 +101,6 @@
(display ")" port) (display ")" port)
(get-output-string port)))) (get-output-string port))))
(record-set! <array> 'writer print-array)
(export make-array (export make-array
array array
array? array?