mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Google Common Lisp Style Guide, revision 1.16
This commit is contained in:
parent
c55433cd2e
commit
1407ba71db
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<p align="right">
|
<p align="right">
|
||||||
|
|
||||||
Revision 1.15
|
Revision 1.16
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -50,23 +50,22 @@ Robert Brown
|
|||||||
<p>
|
<p>
|
||||||
This guide recommends formatting and stylistic choices
|
This guide recommends formatting and stylistic choices
|
||||||
designed to make your code easier for other people to understand.
|
designed to make your code easier for other people to understand.
|
||||||
Its guidelines apply to all the Common Lisp code we write at Google,
|
For those internal applications and free software libraries that
|
||||||
including our internal applications as well as
|
we develop at Google,
|
||||||
free software libraries we maintain and publish.
|
you should keep within these guidelines when making changes.
|
||||||
If you contribute to this code base,
|
Note however that each project has its own rules and customs
|
||||||
you must follow these guidelines before you submit your patch,
|
that complement or override these general guidelines;
|
||||||
or your code will be fixed to follow the guidelines after you do.
|
the speed-oriented QPX low fare search engine notably
|
||||||
|
has a very different style and feel from the QRes reservation system.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you're writing Common Lisp code outside Google,
|
If you're writing Common Lisp code outside Google,
|
||||||
we invite you to consider the guidelines we expound in this guide.
|
we invite you to consider these guidelines.
|
||||||
You may apply some or all of them to your own projects, at your leisure:
|
You may find some of them useful
|
||||||
we hope you find them as useful as we do.
|
where they don't conflict with other priorities you have.
|
||||||
Even if you don't, we welcome remarks and constructive feedback
|
We welcome remarks and constructive feedback
|
||||||
you may have on how to improve our guide, and
|
on how to improve our guide, and
|
||||||
what alternate styles work are successful for you.
|
on what alternate styles work for you and why.
|
||||||
Finally, we hope that our guide will inspire useful thoughts
|
|
||||||
in hackers who read it, especially so newcomers to Common Lisp.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -3031,7 +3030,7 @@ Robert Brown
|
|||||||
and make sure not to leak sensitive data this way.
|
and make sure not to leak sensitive data this way.
|
||||||
These are meant for interactive use,
|
These are meant for interactive use,
|
||||||
and can cause interesting damage
|
and can cause interesting damage
|
||||||
if they cause data or control leak to attackers.
|
if they cause data or control to leak to attackers.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You must not use gratuitous single quotes in <code>CASE</code> forms.
|
You must not use gratuitous single quotes in <code>CASE</code> forms.
|
||||||
@ -3556,7 +3555,7 @@ Robert Brown
|
|||||||
and does not risk going beyond <code>CALL-ARGUMENTS-LIMIT</code>
|
and does not risk going beyond <code>CALL-ARGUMENTS-LIMIT</code>
|
||||||
on implementations where that limit is small,
|
on implementations where that limit is small,
|
||||||
which could blow away the stack on long lists
|
which could blow away the stack on long lists
|
||||||
(we want our code to not be gratuitously unportable).
|
(we want to avoid gratuitous non-portability in our code).
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
However, you must be careful not to use <code>REDUCE</code>
|
However, you must be careful not to use <code>REDUCE</code>
|
||||||
@ -3588,18 +3587,18 @@ Robert Brown
|
|||||||
when you need to update a variable.
|
when you need to update a variable.
|
||||||
You should probably not depend on games
|
You should probably not depend on games
|
||||||
being played with the <code>CDR</code>
|
being played with the <code>CDR</code>
|
||||||
of the current cons cell;
|
of the current CONS cell
|
||||||
and if you do, you must include a prominent
|
(which some might argue is suggested but not guaranteed by the specification);
|
||||||
|
if you do, you must include a prominent
|
||||||
comment explaining the use of <code>NCONC</code>;
|
comment explaining the use of <code>NCONC</code>;
|
||||||
and you should probably reconsider your data representation.
|
and you should probably reconsider your data representation strategy.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
By extension, you should avoid <code>MAPCAN</code>
|
By extension, you should avoid <code>MAPCAN</code>
|
||||||
or the <code>NCONC</code> feature of <code>LOOP</code>.
|
or the <code>NCONC</code> feature of <code>LOOP</code>.
|
||||||
You should instead respectively use
|
You should instead respectively use
|
||||||
<code>ALEXANDRIA:MAPPEND</code>
|
<code>ALEXANDRIA:MAPPEND</code>
|
||||||
and the <code>APPEND</code> feature of <code>LOOP</code>
|
and the <code>APPEND</code> feature of <code>LOOP</code>.
|
||||||
respectively.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<code>NCONC</code> is very seldom a good idea,
|
<code>NCONC</code> is very seldom a good idea,
|
||||||
@ -3626,7 +3625,8 @@ Robert Brown
|
|||||||
where the use of lists as a data structure has been vetted
|
where the use of lists as a data structure has been vetted
|
||||||
because these lists are known to be short,
|
because these lists are known to be short,
|
||||||
and when the function or expression the result of which are accumulated
|
and when the function or expression the result of which are accumulated
|
||||||
explicitly promises in its contract that it only returns fresh lists.
|
explicitly promises in its contract that it only returns fresh lists
|
||||||
|
(in particular, it can't be a constant quote or backquote expression).
|
||||||
Even then, the use of such primitives must be rare,
|
Even then, the use of such primitives must be rare,
|
||||||
and accompanied by justifying documentation.
|
and accompanied by justifying documentation.
|
||||||
</p>
|
</p>
|
||||||
@ -3673,6 +3673,7 @@ Robert Brown
|
|||||||
Unlike the case of <code>#'symbol</code> vs <code>'symbol</code>,
|
Unlike the case of <code>#'symbol</code> vs <code>'symbol</code>,
|
||||||
it is only a syntactic difference with no semantic impact,
|
it is only a syntactic difference with no semantic impact,
|
||||||
except that the former works on Genera and the latter doesn't.
|
except that the former works on Genera and the latter doesn't.
|
||||||
|
|
||||||
You must use the former style if your code is intended as a library
|
You must use the former style if your code is intended as a library
|
||||||
with maximal compatibility to all Common Lisp implementations;
|
with maximal compatibility to all Common Lisp implementations;
|
||||||
otherwise, it is optional which style you use.
|
otherwise, it is optional which style you use.
|
||||||
@ -3886,7 +3887,7 @@ Robert Brown
|
|||||||
</small>
|
</small>
|
||||||
|
|
||||||
<p align="right">
|
<p align="right">
|
||||||
Revision 1.15
|
Revision 1.16
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user