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