[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/08: doc: Recommend 'match-record'.
From: |
guix-commits |
Subject: |
05/08: doc: Recommend 'match-record'. |
Date: |
Thu, 1 Dec 2022 18:05:48 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit cc9ee514e37f6ec74dd9cab91a13d51f7b8d47e7
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Nov 19 22:40:35 2022 +0100
doc: Recommend 'match-record'.
* doc/contributing.texi (Data Types and Pattern Matching): Recommend
'match-record'.
---
doc/contributing.texi | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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
- branch master updated (c7793b82ef -> 00ddf185e6), guix-commits, 2022/12/01
- 04/08: records: 'match-record' checks fields at macro-expansion time., guix-commits, 2022/12/01
- 02/08: etc: teams: Add chez.scm to Racket team's scope., guix-commits, 2022/12/01
- 05/08: doc: Recommend 'match-record'.,
guix-commits <=
- 01/08: gnu: guile-gcrypt: Update to 0.4.0., guix-commits, 2022/12/01
- 06/08: home: services: Use 'match-record' instead of 'match'., guix-commits, 2022/12/01
- 07/08: services: base: Use 'match-record' instead of 'match'., guix-commits, 2022/12/01
- 03/08: gnu: Add alfa., guix-commits, 2022/12/01
- 08/08: services: networking: Avoid 'match' on records., guix-commits, 2022/12/01