aboutsummaryrefslogtreecommitdiff
path: root/HACKING
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-09-07 15:51:29 +0200
committerLudovic Courtès <ludo@gnu.org>2013-09-07 15:51:29 +0200
commit2df74ac1175225b1e3080acb3e7ea61ad16424f6 (patch)
tree8f140cf0eb838bbf0b2de2c13057f4b72a093317 /HACKING
parenta129e0d877f125693f58457d55973d184468b461 (diff)
downloadguix-2df74ac1175225b1e3080acb3e7ea61ad16424f6.tar.gz
guix-2df74ac1175225b1e3080acb3e7ea61ad16424f6.zip
doc: Add "Data Types and Pattern Matching" to the Coding Style.
* HACKING (Data Types and Pattern Matching): New section.
Diffstat (limited to 'HACKING')
-rw-r--r--HACKING12
1 files changed, 12 insertions, 0 deletions
diff --git a/HACKING b/HACKING
index 85e9a900be..ef8fb27cbe 100644
--- a/HACKING
+++ b/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.