From: John Wiseman
Subject: Re: autoload lisp packages?
Date: 
Message-ID: <arxpvqe4a9j.fsf@gargoyle164.cs.uchicago.edu>
SDS <···········@cctrading.com> writes:

> I am somewhat confused by the Lisp packaging system.
> I use CLISP and I downloaded metering.lsp (for profiling).
> I want to profile my code only sometimes, and I do not want to load
> metering every single time.
> But I can neither eval nor compile a function containg
> 
> 	(cond (whatever
> 		(load "metering.fas")
> 		(mon:monitor-form (form)))
> 	      (t (form)))
> 
> if metering is not loaded, I get an error that there is no such package
> as mon. Of course there is no such package *yet*, but I am not calling
> anything from that package *yet*, right?

One problem is that Lisp needs the MONITOR package to exist at the
time your cond form is _read_ in order to intern the symbol
MONITOR-FORM in the right place.  To get around this, I usually do
something like the following:

	(cond (whatever
	       (load "metering.fas")
	       (funcall (symbol-function (find-symbol "MONITOR-FORM" "MON"))
                        (form)))
	      (T
	       (form)))

But another problem in your case is that the above code will not work
because MONITOR-FORM is a macro.  It simply must be defined at the
time your code is evaled or loaded or compiled.  So instead, try to
get the functionality the macro provides by calling functions (you
could try using MONITOR-ALL and MONITORING-UNENCAPSULATE).


John Wiseman