mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
doc: Add "Data Types and Pattern Matching" to the Coding Style.
* HACKING (Data Types and Pattern Matching): New section.
This commit is contained in:
parent
a129e0d877
commit
2df74ac117
1 changed files with 12 additions and 0 deletions
12
HACKING
12
HACKING
|
@ -108,6 +108,18 @@ However, it is OK for a “host-side” module to use a build-side module.
|
|||
Modules that deal with the broader GNU system should be in the (gnu …) name
|
||||
space rather than (guix …).
|
||||
|
||||
** Data Types and Pattern Matching
|
||||
|
||||
The tendency in classical Lisp is to use lists to represent everything, and
|
||||
then to browse them “by hand” using ‘car’, ‘cdr’, ‘cadr’, and co. There are
|
||||
several problems with that style, notably the fact that it is hard to read,
|
||||
error-prone, and a hindrance to proper type error reports.
|
||||
|
||||
Guix code should define appropriate data types (for instance, using
|
||||
‘define-record-type*’) rather than abuse lists. In addition, it should use
|
||||
pattern matching, via Guile’s (ice-9 match) module, especially when matching
|
||||
lists.
|
||||
|
||||
** Formatting Code
|
||||
|
||||
When writing Scheme code, we follow common wisdom among Scheme programmers.
|
||||
|
|
Loading…
Reference in a new issue