refactor record type bootstrap
This commit is contained in:
parent
0eecddb5da
commit
8a5a3e6b97
|
@ -746,16 +746,10 @@
|
|||
|
||||
;; 5.5 Recored-type definitions
|
||||
|
||||
(import (picrin record))
|
||||
(import (picrin record)
|
||||
(scheme write))
|
||||
|
||||
(define <record-type> #t) ; bootstrap
|
||||
|
||||
(import (scheme write))
|
||||
|
||||
(define (make-record-type name ctor)
|
||||
(let ((rectype (make-record <record-type>)))
|
||||
(record-set! rectype 'name name)
|
||||
(record-set! rectype 'writer (lambda (obj)
|
||||
(define ((default-record-writer ctor) obj)
|
||||
(let ((port (open-output-string)))
|
||||
(display "#.(" port)
|
||||
(display (car ctor) port)
|
||||
|
@ -765,14 +759,22 @@
|
|||
(write (record-ref obj field) port))
|
||||
(cdr ctor))
|
||||
(display ")" port)
|
||||
(get-output-string port))))
|
||||
(get-output-string port)))
|
||||
|
||||
(define ((boot-make-record-type <meta-type>) name ctor)
|
||||
(let ((rectype (make-record <meta-type>)))
|
||||
(record-set! rectype 'name name)
|
||||
(record-set! rectype 'writer (default-record-writer ctor))
|
||||
rectype))
|
||||
|
||||
(set! <record-type>
|
||||
(let ((<record-type> (make-record-type '<record-type> '(name writer))))
|
||||
(define <record-type>
|
||||
(let ((<record-type>
|
||||
((boot-make-record-type #t) 'record-type '(record-type name writer))))
|
||||
(record-set! <record-type> '@@type <record-type>)
|
||||
<record-type>))
|
||||
|
||||
(define make-record-type (boot-make-record-type <record-type>))
|
||||
|
||||
(define-syntax define-record-constructor
|
||||
(ir-macro-transformer
|
||||
(lambda (form inject compare?)
|
||||
|
|
Loading…
Reference in New Issue