diff options
author | Andy Wingo <wingo@pobox.com> | 2019-10-22 14:50:14 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-10-22 14:50:14 +0200 |
commit | 4bec125e634d88afabdc3cac16566144ccbf6d5f (patch) | |
tree | a0f127e415d28b6500ec75e1653c378f9c253dca /module/srfi/srfi-9.scm | |
parent | 6205c2d7d44b3be61d01b697efe38a8b6a3c5b26 (diff) | |
download | guile-4bec125e634d88afabdc3cac16566144ccbf6d5f.tar.gz |
Allow records to be subtyped
* module/ice-9/boot-9.scm (record-type-vtable): Add slots for "flags"
and a parent vector.
(record-type-name, record-type-fields): Move up in the file.
(record-type-constructor, record-type-flags, record-type-parents): New
accessors.
(make-record-type): Take #:final? and #:parent keyword arguments.
(record-constructor): Delegate to record-type-constructor.
(record-predicate): For non-final types --types that can be extended
by subtyping -- implement an O(1) type predicate.
(define-record-type): Initialize the new fields.
* module/srfi/srfi-9.scm (%define-record-type): Initialize flags and
parent fields.
Diffstat (limited to 'module/srfi/srfi-9.scm')
-rw-r--r-- | module/srfi/srfi-9.scm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/module/srfi/srfi-9.scm b/module/srfi/srfi-9.scm index aee8be01c..58b588b00 100644 --- a/module/srfi/srfi-9.scm +++ b/module/srfi/srfi-9.scm @@ -320,7 +320,10 @@ '#,(datum->syntax #'here (make-struct-layout layout)) default-record-printer 'type-name - '#,field-ids))) + '#,field-ids + #f ; Constructor. + '(final) ; Flags. + #()))) ; Parents. (set-struct-vtable-name! rtd 'type-name) (struct-set! rtd (+ 2 vtable-offset-user) #,ctor-name) rtd)) |