diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-11-19 22:40:35 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-12-08 13:21:35 +0100 |
| commit | 883aa80b45c10628322c52f9912188d3a85b5639 (patch) | |
| tree | f15d68136852637faeb65fe3903255063dc020cd | |
| parent | 754a7660a1716998b557aedeb805ee9040afdcdf (diff) | |
doc: Recommend 'match-record'.
* doc/contributing.texi (Data Types and Pattern Matching): Recommend
'match-record'.
| -rw-r--r-- | doc/contributing.texi | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/contributing.texi b/doc/contributing.texi index 40ae33ecaca..6a8ffd65244 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}, | |||
| 1089 | notably the fact that it is hard to read, error-prone, and a hindrance | 1089 | notably the fact that it is hard to read, error-prone, and a hindrance |
| 1090 | to proper type error reports. | 1090 | to proper type error reports. |
| 1091 | 1091 | ||
| 1092 | @findex define-record-type* | ||
| 1093 | @findex match-record | ||
| 1094 | @cindex pattern matching | ||
| 1092 | Guix code should define appropriate data types (for instance, using | 1095 | Guix code should define appropriate data types (for instance, using |
| 1093 | @code{define-record-type*}) rather than abuse lists. In addition, it | 1096 | @code{define-record-type*}) rather than abuse lists. In addition, it |
| 1094 | should use pattern matching, via Guile’s @code{(ice-9 match)} module, | 1097 | should use pattern matching, via Guile’s @code{(ice-9 match)} module, |
| 1095 | especially when matching lists (@pxref{Pattern Matching,,, guile, GNU | 1098 | especially when matching lists (@pxref{Pattern Matching,,, guile, GNU |
| 1096 | Guile Reference Manual}). | 1099 | Guile Reference Manual}); pattern matching for records is better done |
| 1100 | using @code{match-record} from @code{(guix records)}, which, unlike | ||
| 1101 | @code{match}, verifies field names at macro-expansion time. | ||
| 1097 | 1102 | ||
| 1098 | @node Formatting Code | 1103 | @node Formatting Code |
| 1099 | @subsection Formatting Code | 1104 | @subsection Formatting Code |
