add define-record-writer
This commit is contained in:
parent
53a732e9c4
commit
75138db4db
|
@ -6,6 +6,7 @@ list(APPEND PICLIB_SCHEME_LIBS
|
||||||
|
|
||||||
${PROJECT_SOURCE_DIR}/piclib/scheme/base.scm
|
${PROJECT_SOURCE_DIR}/piclib/scheme/base.scm
|
||||||
|
|
||||||
|
${PROJECT_SOURCE_DIR}/piclib/picrin/record.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/picrin/array.scm
|
${PROJECT_SOURCE_DIR}/piclib/picrin/array.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/picrin/dictionary.scm
|
${PROJECT_SOURCE_DIR}/piclib/picrin/dictionary.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/picrin/test.scm
|
${PROJECT_SOURCE_DIR}/piclib/picrin/test.scm
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
(define-library (picrin record)
|
||||||
|
(import (scheme base))
|
||||||
|
|
||||||
|
(define (define-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
|
||||||
|
(lambda (obj)
|
||||||
|
body ...)))
|
||||||
|
((_ type writer)
|
||||||
|
(define-record-writer* type
|
||||||
|
writer))))
|
||||||
|
|
||||||
|
(export define-record-writer))
|
Loading…
Reference in New Issue