refactor define-record-writer
This commit is contained in:
parent
85ccc30821
commit
6f40dcc5df
|
@ -1,17 +1,17 @@
|
||||||
(define-library (picrin record)
|
(define-library (picrin record)
|
||||||
(import (scheme base))
|
(import (scheme base))
|
||||||
|
|
||||||
(define (define-record-writer* record-type writer)
|
(define (set-record-writer! record-type writer)
|
||||||
(record-set! record-type 'writer writer))
|
(record-set! record-type 'writer writer))
|
||||||
|
|
||||||
(define-syntax define-record-writer
|
(define-syntax define-record-writer
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ (type obj) body ...)
|
((_ (type obj) body ...)
|
||||||
(define-record-writer* type
|
(set-record-writer! type
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
body ...)))
|
body ...)))
|
||||||
((_ type writer)
|
((_ type writer)
|
||||||
(define-record-writer* type
|
(set-record-writer! type
|
||||||
writer))))
|
writer))))
|
||||||
|
|
||||||
(export define-record-writer))
|
(export define-record-writer))
|
||||||
|
|
Loading…
Reference in New Issue