Subject: Re: fun with eval-when and compile-file
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 08 Jan 2003 06:12:00 -0600
Newsgroups: comp.lang.lisp
Message-ID: <aN2dna0KtJENiIGjXTWcqA@giganews.com>
Kent M Pitman  <pitman@world.std.com> wrote:
+---------------
| Tim Bradshaw <tfb@cley.com> writes:
| > And in this case you almost certainly will not need the EVAL-WHEN,
| > either: DEFINE-THING will expand to code which refers to *THINGS*, but
| > this code will not actually run until the file is loaded, when
| > *THINGS* and the utility functions will be defined in the normal way.
| 
| The usual case is that an EVAL-WHEN is needed in the expansion if you plan
| to use the macro you're defining later in the same file and not otherwise.
+---------------

I've found that in order to compile-file files that REQUIRE other
compiled macro-containing modules, I have to wrap the REQUIREs in
EVAL-WHEN. For example, the prolog for my CGI-SQL module (that supports
CGI scripting in either CMUCL or CLISP) that uses Tim Bradshaw's HTOUT
macros & Eric Marsden's POSTGRESQL macros (except on CLISP, where for
now I'm still using the PostgreSQL binding bundled into the distribution)
had to be this to get it to compile:

    (eval-when (:compile-toplevel :load-toplevel :execute)  ; for the macros
      (require :htout)
      (require :cgi)
      #-clisp          ; May be removed later if move to PG for CLISP, too.
      (require :pg))

    (defpackage :cgi-sql
      (:use :cl :ext :htout #-clisp :pg)
      #+clisp ; conflicts with CLISP's EXT
      (:shadowing-import-from :htout #:with-html-output)
      (:export #:sql-result-html-table   ; (sql-result &key stream callback)
	       #:list-html-table         ; (lists &key stream callback)
	       ...etc... )

    (in-package :cgi-sql)
    (provide :cgi-sql)

    ...etc...

Am I missing something obvious that would let me omit the EVAL-WHEN?


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607