Subject: Re: eval-when?
From: Erik Naggum <erik@naggum.no>
Date: 1999/11/03
Newsgroups: comp.lang.lisp
Message-ID: <3150616834270740@naggum.no>

* Andrew Cooke
| I have some code that may (or may not) use another package.  If the code
| is being used independently, I need to define something myself.  So I
| have some top-level code that looks like:
| 
| (cond ((find-package "ZB")
|        (print "using zebu"))
|       (t
|        (print "no zebu")
|        (defstruct kb-domain)))
| 
| But this doesn't work when the other package is present - kb-domain ends
| up being defined in the current package and in ZB.  I guess (I'm new to
| this) that kb-domain as a symbol has been created by the reader, hence
| the conflict.

  you guessed right.

| Can anyone tell me what I am doing wrong (at any level of abstraction
| below "using Lisp") - or, better, what I should be doing here?

  you can easily use the reader to support this shared-mode development.
  the key is to use #+ and #- and to add your own feature to the *FEATURES*
  list.  to make sure this happens at the right time, you need to keep a
  few things straight, however.

;;first set up the feature in the reader -- make sure the value is harmless
#.(progn
    (if (find-package "ZB")
      (pushnew :zebu *features*)
      (drop :zebu *features*))
    nil)

;;now we can use conditional reader forms to select or skip forms
#+zebu (print "using zebu")
#-zebu (print "no zebu")

  hope this helps.

#:Erik