diff options
author | Andy Wingo <wingo@pobox.com> | 2019-10-27 20:51:49 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-10-27 20:55:01 +0100 |
commit | 7a8e314d31ef8d40dd692bc27a93bc30c328e2b7 (patch) | |
tree | c4792f0516f132612fdca4959db6906e0efb751c /doc/ref/api-data.texi | |
parent | 958aa8b313f771c281168ed56b23f2f8aebb72cc (diff) | |
download | guile-7a8e314d31ef8d40dd692bc27a93bc30c328e2b7.tar.gz |
Guile `make-record-type' supports non-generative definition
* module/ice-9/boot-9.scm (prefab-record-types): New definition.
(make-record-type): Add #:uid keyword.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Document #:uid
Diffstat (limited to 'doc/ref/api-data.texi')
-rw-r--r-- | doc/ref/api-data.texi | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 9b6cd88d4..d7af7754a 100644 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -8631,7 +8631,7 @@ promise that records are disjoint with other Scheme types. @end deffn @deffn {Scheme Procedure} make-record-type type-name field-names [print] @ - [#:final?=@code{#t}] [parent=@code{#f}] + [#:final?=@code{#t}] [#:parent=@code{#f}] [#:uid=@code{#f}] Create and return a new @dfn{record-type descriptor}. @var{type-name} is a string naming the type. Currently it's only used @@ -8659,6 +8659,18 @@ work on any instance of a subtype. Allowing record subtyping has a small amount of overhead. To avoid this overhead, declare the record type as @dfn{final} by passing @code{#:final? #t}. Record types in Guile are final by default. + +@cindex prefab record types +@cindex record types, prefab +@cindex record types, nongenerative +Generally speaking, calling @code{make-record-type} returns a fresh +record type; it @emph{generates} new record types. However sometimes +you only want to define a record type if one hasn't been defined +already. For a @emph{nongenerative} record type definition, pass a +symbol as the @code{#:uid} keyword parameter. If a record with the +given @var{uid} was already defined, it will be returned instead. The +type name, fields, parent (if any), and so on for the previously-defined +type must be compatible. @end deffn @deffn {Scheme Procedure} record-constructor rtd |