Next: 5.5 Tail Recursion
Up: 5.4 Source Optimization
Previous: 5.4.7 Source to Source
Source level optimization makes possible a clearer and more relaxed programming
style:
- Don't use macros purely to avoid function call. If you want an
inline function, write it as a function and declare it inline. It's
clearer, less error-prone, and works just as well.
- Don't write macros that try to ``optimize'' their expansion in
trivial ways such as avoiding binding variables for simple
expressions. The compiler does these optimizations too, and is less
likely to make a mistake.
- Make use of local functions (i.e., labels or flet)
and tail-recursion in places where it is clearer. Local function
call is faster than full call.
- Avoid setting local variables when possible. Binding a new
let variable is at least as efficient as setting an existing
variable, and is easier to understand, both for the compiler and the
programmer.
- Instead of writing similar code over and over again so that it
can be hand customized for each use, define a macro or inline
function, and let the compiler do the work.
Raymond Toy
Mon Jul 14 09:11:27 EDT 1997