aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-11-19 22:40:35 +0100
committerLudovic Courtès <ludo@gnu.org>2022-12-08 13:21:35 +0100
commit883aa80b45c10628322c52f9912188d3a85b5639 (patch)
treef15d68136852637faeb65fe3903255063dc020cd
parent754a7660a1716998b557aedeb805ee9040afdcdf (diff)
downloadguix-883aa80b45c10628322c52f9912188d3a85b5639.tar
guix-883aa80b45c10628322c52f9912188d3a85b5639.tar.gz
doc: Recommend 'match-record'.
* doc/contributing.texi (Data Types and Pattern Matching): Recommend 'match-record'.
-rw-r--r--doc/contributing.texi7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 40ae33ecac..6a8ffd6524 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1089,11 +1089,16 @@ and then to browse them ``by hand'' using @code{car}, @code{cdr},
notably the fact that it is hard to read, error-prone, and a hindrance
to proper type error reports.
+@findex define-record-type*
+@findex match-record
+@cindex pattern matching
Guix code should define appropriate data types (for instance, using
@code{define-record-type*}) rather than abuse lists. In addition, it
should use pattern matching, via Guile’s @code{(ice-9 match)} module,
especially when matching lists (@pxref{Pattern Matching,,, guile, GNU
-Guile Reference Manual}).
+Guile Reference Manual}); pattern matching for records is better done
+using @code{match-record} from @code{(guix records)}, which, unlike
+@code{match}, verifies field names at macro-expansion time.
@node Formatting Code
@subsection Formatting Code