Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

circular dependencies: what is "The Right Thing"?

56 views
Skip to first unread message

Barry Margolin

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

In article <m3hg5ui...@mute.eaglets.com>,
Sam Steingold <s...@usa.net> wrote:
>I have file str.lsp, which defines a structure STR and works with it,
>and a file plot.lsp, which defines some plotting functions, including
>the function plot-str which plots instances of STR. I want to use
>plot-str in str.lsp. Now clearly str.lsp has to be loaded when plot.lsp
>is being compiled. OTOH, when I compile str.lsp, the compiler complains
>that plot-str is undefined. I understand that it is safe to ignore the
>warning, but I wonder if there is a way to tell the compiler in advance
>that plot-str will be defined soon. In Emacs Lisp I use autoload for
>this purpose (it allows me to weed out mistyped function names). Is
>there a good way to deal with this (non)problem?

The macro WITH-COMPILATION-UNIT is intended to resolve this problem. You
would do:

(with-compilation-unit ()
(compile-file "str.lsp")
(load "str")
(compile-file "plot.lsp"))

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.

Erik Naggum

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

* Sam Steingold
| 2. Jaari Aalto asked a similar question (about ELisp) some time ago, and
| Erik Naggum said that asking this question demonstrates ignorance about
| lisp philosophy. So I know this, and if this is the only thing you want
| to say, you don't have to. :-)

well, Jari Aalto's questions are all ignorant of the Lisp philosophy
(after 5 years he has learned less than my cat did the first month she
spent in my lap while I was programming), so my answer doesn't really
have anything to with the _general_ topic at hand, only his _specific_
"problems". don't make the mistake of thinking that all the stuff he's
doing is not worth doing or finding out -- it is that somebody who is so
profoundly uninterested in doing it right does it that is the problem.

to your question: generally speaking, you need to load Lisp definitions
in the order they are needed. macros first, then typically types and
classes. variables that are declared special must be known to the
compiler before functions that bind or reference them are compiled.
complex defgeneric forms need to go before the first method. etc. it
might be wise to arrange files to be compiled and loaded in these terms
since Lisp doesn't really provide "forward declarations", but there's
nothing to say a different order is a violation of anything or that you
won't succeed with a different order, it just makes sense to make a small
set of rules for yourself that keeps your mind of these problems.

#:Erik
--
God grant me serenity to accept the code I cannot change,
courage to change the code I can, and wisdom to know the difference.

0 new messages