refactor define-record-writer

This commit is contained in:
Yuichi Nishiwaki 2014-09-04 19:14:43 +09:00
parent 85ccc30821
commit 6f40dcc5df
1 changed files with 3 additions and 3 deletions

View File

@ -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))