diff options
author | Andy Wingo <wingo@pobox.com> | 2019-10-28 16:58:22 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-10-28 16:59:58 +0100 |
commit | 315fabdfe7122737ca9a804097ff16dabfd7a63a (patch) | |
tree | bedc0edf9abe43bad1d3bd6535c710019be7dca8 /doc/ref/api-data.texi | |
parent | f963bdf02d7dd316884ccc9d590b3a7327406422 (diff) | |
download | guile-315fabdfe7122737ca9a804097ff16dabfd7a63a.tar.gz |
Add support for immutable fields in core records
* module/ice-9/boot-9.scm (make-record-type): Allow (mutable NAME)
or (immutable NAME) as a field name, and record field mutability in a
bitfield.
(record-modifier): Throw an error if the field isn't mutable.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Update.
Diffstat (limited to 'doc/ref/api-data.texi')
-rw-r--r-- | doc/ref/api-data.texi | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 3385571c2..2708ad5c7 100644 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -8637,8 +8637,10 @@ Create and return a new @dfn{record-type descriptor}. @var{type-name} is a string naming the type. Currently it's only used in the printed representation of records, and in diagnostics. -@var{field-names} is a list of symbols naming the fields of a record -of the type. Duplicates are not allowed among these symbols. +@var{field-names} is a list of elements of the form @code{(immutable +@var{name})}, @code{(mutable @var{name})}, or @var{name}, where +@var{name} are symbols naming the fields of a record of the type. +Duplicates are not allowed among these symbols. @example (make-record-type "employee" '(name age salary)) @@ -8680,6 +8682,11 @@ the record type. @xref{rnrs records procedural}, for full details. The @code{#:opaque?} flag is used by Guile's R6RS layer to record this information. The default is determined by whether the parent type, if any, was opaque. + +Fields are mutable by default, meaning that @code{record-modifier} will +return a procedure that can update a record in place. Specifying a +field using the form @code{(immutable @var{name})} instead marks a field +as immutable. @end deffn @deffn {Scheme Procedure} record-constructor rtd |