~ chicken-core (chicken-5) 3887db2a7434f2a494ca14bacd419c594f66d4e9
commit 3887db2a7434f2a494ca14bacd419c594f66d4e9
Author: Alaric Snell-Pym <alaric@snell-pym.org.uk>
AuthorDate: Sun Nov 20 20:15:58 2011 +0000
Commit: Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Fri Mar 9 11:51:50 2012 +0100
Clarified the define-record documentation
I hope it's a clarification, at least. I found the original
definition a bit terse for my tastes.
Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>
diff --git a/manual/Non-standard macros and special forms b/manual/Non-standard macros and special forms
index 8a942647..c6865547 100644
--- a/manual/Non-standard macros and special forms
+++ b/manual/Non-standard macros and special forms
@@ -385,10 +385,17 @@ Equivalent to:
<macro>(define-record NAME SLOTNAME ...)</macro>
-Defines a record type. Call {{make-NAME}} to create an instance
-of the structure (with one initialization-argument for each slot).
+Defines a record type. This defines a number of procedures for
+creating, accessing, and modifying record members.
+
+Call {{make-NAME}} to create an instance
+of the structure (with one initialization-argument for each slot, in
+the listed order).
+
{{(NAME? STRUCT)}} tests any object for being an instance of this
-structure. Slots are accessed via {{(NAME-SLOTNAME STRUCT)}}
+structure.
+
+Slots are accessed via {{(NAME-SLOTNAME STRUCT)}}
and updated using {{(NAME-SLOTNAME-set!}} {{STRUCT}} {{VALUE)}}.
<enscript highlight=scheme>
@@ -400,13 +407,26 @@ and updated using {{(NAME-SLOTNAME-set!}} {{STRUCT}} {{VALUE)}}.
(point-y p1) ==> 99
</enscript>
+===== SRFI-17 setters
+
{{SLOTNAME}} may alternatively also be of the form
(setter SLOTNAME)
-In this case the slot can be read with {{(NAME-SLOTNAME STRUCT)}}
-and written with {{(set! (NAME-SLOTNAME STRUCT) VALUE)}} (the slot-accessor
-has an associated SRFI-17 "setter" procedure).
+In this case the slot can be read with {{(NAME-SLOTNAME STRUCT)}} as usual,
+and modified with {{(set! (NAME-SLOTNAME STRUCT) VALUE)}} (the slot-accessor
+has an associated SRFI-17 "setter" procedure) instead of
+the usual {{(NAME-SLOTNAME-set!}} {{STRUCT}} {{VALUE)}}.
+
+
+<enscript highlight=scheme>
+(define-record point (setter x) (setter y))
+(define p1 (make-point 123 456))
+(point? p1) ==> #t
+(point-x p1) ==> 123
+(set! (point-y p1) 99)
+(point-y p1) ==> 99
+</enscript>
==== define-record-type
Trap