Re: organizing lisp code
- From: liyer.vijay@xxxxxxxxx
- Date: 30 May 2006 19:28:12 -0700
JesusWaffle@xxxxxxxxx wrote:
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.
Okay. That sounds good.
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.
This I have never encountered before (though I admit that I
haven't encoutered much in Lisp) I thought that CLOS' lack
of support for encapsulation had it's own reasons and that
that programmers just exported the symbols that are `public'
so to speak. Peter Seibel in PCL says something along these
very lines I think (I don't own the book but mostly follow
it online -- it's on my wish-list and I'm hoping someone
buys it for me soon ;-)) and I think he also says that if
necessary, a programmer can use an un-exported symbol if the
author has forgotten to do the same. And I believe that
Lispers consider lack of encapsulation a feature than a
loss.
Do you know how commonly this %private-symbol convention
is used?
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.
Can I say that all defconstants (related to a module) would
go into one single file?
Would the defparameters and defvars go in this same file?
Or would they be coupled with the module file where the
classes etc are defined?
Hope that helps!
It does. Thanks :)
Cheers
Vijay Lakshminarayanan
.
- References:
- organizing lisp code
- From: liyer . vijay
- Re: organizing lisp code
- From: JesusWaffle
- organizing lisp code
- Prev by Date: Re: Relative merits of Lisp-1 vs. Lisp-2?
- Next by Date: Re: organizing lisp code
- Previous by thread: Re: organizing lisp code
- Next by thread: Re: organizing lisp code
- Index(es):
Relevant Pages
|