文档介绍:Lisp Users and V endo rs Conference
August
T uto rial on
Go o d Lisp Programming
St yle
P eter No rvig
Sun Microsystems Labs Inc
Kent Pitman
Ha rlequin
Inc
c
P o rtions cop yright
P eter No rvig
c
P o rtions cop yright
Kent M
Pitman
All Rights Reserved
Outline
What is Go o d St yle
Tips on Built
In F unctionalit y
Tips on Nea r
Standa rd T ools
Kinds of Abstraction
Programming in the La rge
Miscellaneous
What is Go o d St yle
Good Lisp Programming St yle
Elegance is not optional
Richa rd A
O
Keefe
Good st yle
in any language
leads to p rograms that
a re
Understandable
Reusable
Extensible
E
cient
Easy to develop
debug
It also helps co rrectness
robustness
compatibil i t y
Our maxims of go o d st yle a re
Be explicit
Be sp eci
c
Be concise
Be consistent
Be helpful
anticipate the reader
s needs
Be conventional
don
t b e obscure
Build abstractions at a usable level
Allo w to ols to interact
referential transpa rency
Good st yle is the
underw a re
that supp o rtsap rogram
Where do es go o d st e from
What T o Believe
Don
t b elieve everything w e tell y ou
Just most
W o rry less ab out what to b elieve and mo re ab out why
Kno w where y our
St yle Rules
come from
Religion
Go o d vs
Evil
This w a y is b etter
Philosophy
This is consistent with other things
Robustness
Liabilit y
Safet y
Ethics
I
ll put in
redundant checks to avoid something ho rrible
Legalit y
Our la wy ers sa ydoitthisw a y
P ersonalit y
Opinion
I lik e it this w a y
Compatibilit y
Another to ol exp ects this w a y
P o rtabilit y
pilers p refer this w a y
Co op eration
Convention
It has to be done
some unifo rm w a y
sow e agreed on this one
Habit
T radition
W e
ve alw a ys done it this w a y
Abilit y
My p rogram