1
- SBCL Style Guide
1
+ SBCL Hacking Guide
2
2
3
3
(This is not a most actively maintained file, but recommended
4
4
reading anyways.)
@@ -7,27 +7,35 @@ Patch Submissions
7
7
=================
8
8
9
9
Preferred patch format is output from "git format-patch", including
10
- the commit message. The commit message should explain the why and how
11
- of the change.
10
+ the commit message.
12
11
13
- Please include test-cases in your patch if at all possible.
12
+ The commit message should explain the why and how of the change. See
13
+ existing commit messages for examples -- for a truly trivial changes
14
+ little is needed, but in most cases more is better.
15
+
16
+ Please include test-cases in your patch if at all possible: if you're
17
+ not sure which file in tests/ to put your test case in, just pick one
18
+ that seems vaguely appropriate.
14
19
15
20
Please format your submission for ease of reading: unless the change
16
21
is whitespace only, avoid re-indenting code you are not touching, etc.
17
- Unless your patch is large and best understood as a series of
18
- sequential changes, please send it in as single patch file.
22
+
23
+ Unless your change is large and best understood as a series of
24
+ sequential changes, please send it in as single patch.
19
25
20
26
If your patch includes algorithmic changes, explain them. If your
21
27
patch uses a published algorithm, please include a link to the paper.
22
28
We aren't always as well-educated as we'd like to...
23
29
24
30
Ready-to-apply patches should be submitted via Launchpad: please add
25
- the tag "review" to the associated bug.
31
+ the tag "review" to the associated bug (create new bug with name if
32
+ there isn't one about the issue yet.)
26
33
27
34
Patches requiring more widespread discussion and feedback should be
28
35
sent to the sbcl-devel mailing list.
29
36
30
- If you have any questions, feel free to ask them on sbcl-devel.
37
+ If you have any questions, feel free to ask them on sbcl-devel,
38
+ or the IRC channel #
[email protected] .
31
39
32
40
Coding Style
33
41
============
@@ -38,12 +46,10 @@ Most of the style hints in the Lisp FAQ apply.
38
46
39
47
When porting code we prefer code which factors dependencies into a set
40
48
of interface functions and constants and includes implementations of
41
- the interface for the different systems. Patches which require
42
- conditional compilation (like all the old
43
- #T+HPUX or #T-X86 tests in the sources inherited from CMUCL) might be
44
- accepted if they're simple, in hopes of factoring out the differences
45
- more cleanly later, but even if accepted, such code may not be
46
- maintained for very long.
49
+ the interface for the different systems.
50
+
51
+ Reader conditionals are frowed upon. Sometimes they're the least
52
+ of all evils, but think thrice.
47
53
48
54
grammatical fussiness:
49
55
Phrases are not capitalized.
@@ -56,6 +62,7 @@ grammatical fussiness:
56
62
;;; solving a system.
57
63
(defvar *max-n-transformations* 10)
58
64
Lisp in comments is capitalized.
65
+ Symbol names are capitalized.
59
66
60
67
usage fussiness:
61
68
Function documentation can be a description of what the function
@@ -87,6 +94,8 @@ usage fussiness:
87
94
;;; When you call this function on X, you get back the first
88
95
;;; prime number greater than or equal to X.
89
96
(defun primify (x) ..)
97
+ Documentation for public functions belongs in a docstring.
98
+ Documentation for internal functions belongs mostly in a comment.
90
99
91
100
In general, if you can express it in the code instead of the comments,
92
101
do so. E.g. the old CMUCL code has many comments above functions foo
@@ -107,20 +116,18 @@ which are not good examples to follow:
107
116
instead of factoring the dependencies into interfaces and providing
108
117
implementations of the interface for different architectures;
109
118
* in conditional compilation, using a common subexpression over and
110
- over again, e.g. #+(OR GENGC GENCGC ), when the important thing is
111
- that GENGC and GENCGC are (currently) the GCs which support scavenger
112
- hooks. If you have to do that, define a SCAVHOOK feature,
113
- write #+SCAVHOOK in many places, and arrange for the SCAVHOOK feature
114
- to be set once and only once in terms of GENGC and GENCGC. (That way
115
- future maintainers won't curse you.)
119
+ over again, e.g. #+(OR X86 X86-64 ), when the important thing is
120
+ that the platform supports single-instruction CAS. If you have to
121
+ do something like that, define a new FOO feature, write #+FOO in
122
+ many places, and arrange for the FOO feature to be set once and
123
+ only once -- probably in make-config.sh. (That way future
124
+ maintainers won't curse you.)
116
125
* putting the defined symbol, and information about whether it's
117
126
exported or not, into the comments around the definition of the symbol;
118
127
* naming anything DO-FOO if it isn't an iteration macro
119
- * exposing a lot of high-level functionality not in the ANSI standard
120
- to the user (as discussed above)
121
128
* not using a consistent abbreviation style in global names (e.g.
122
129
naming some things DEFINE-FOO and other things DEF-BAR, with
123
- no rule to determine whether the abbreviation is used)
130
+ no rule to determine whether the abbreviation is used).
124
131
* using lots of single-colon package prefixes (distracting and hard
125
132
to read, and obstacles to reaching package nirvana where
126
133
package dependencies are a directed acyclic graph) or even
@@ -130,6 +137,6 @@ which are not good examples to follow:
130
137
(DEFUN CL:CADDDR (..) ..) as reminders that they're required by
131
138
ANSI and can't be deleted no matter how obscure and useless some
132
139
of them might look.:-)
133
- Most of these are common in the code inherited from CMUCL. We've
140
+ Many of these are common in the code inherited from CMUCL. We've
134
141
eliminated them in some places, but there's a *lot* of code inherited
135
142
from CMUCL..
0 commit comments