Re: organizing lisp code



Personally, I tend to organize my definitions into logical "modules,"
and put each in a file. There are three guidelines I use to decide what
a module is:

1) The definitions inside a module are usually fairly closely coupled.
Generally, it consists of a few classes, which are often related by
containment or inheritance, and some functions/methods which operate on
those classes.

2) The definitions, when taken together, form a coherent,
information-hiding interface. Unfortunately, as far as I know, there is
no language support for deciding which definitions are interface, and
which are implementation: Common Lisp only has packages, which aren't
fine-grained enough to give one to each module. Some programmers prefix
their "private" symbols with % signs or the like.

3) Once I've split my code into modules, I can make a dependency
ordering on them. I can say, for instance, "module C only uses
definitions from modules A and B, and module B only uses definitions
from module A." I try to organize the modules so that each module has
as few dependencies as possible, and I avoid circular dependencies like
the plague. If you have a circular dependency, it almost always means
that you should move some definitions around, or split off the
troublesome definitions into a separate module.

Hope that helps!
Nick Thomas

.