mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
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.
This commit is contained in:
parent
6205c2d7d4
commit
4bec125e63
2 changed files with 96 additions and 32 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue