home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / lisp / 2125 < prev    next >
Encoding:
Text File  |  1992-07-28  |  1.2 KB  |  34 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!cs.yale.edu!loosemore-sandra
  3. From: loosemore-sandra@CS.YALE.EDU (Sandra Loosemore)
  4. Subject: Re: Help with EVAL-WHEN
  5. In-Reply-To: phil@Xenon.Stanford.EDU's message of Tue, 28 Jul 1992 03: 37:44 GMT
  6. Message-ID: <1992Jul28.120934.9306@cs.yale.edu>
  7. Sender: news@cs.yale.edu (Usenet News)
  8. Nntp-Posting-Host: monad.systemsz.cs.yale.edu
  9. Organization: staff hacker @ Yale Haskell project
  10. References: <1992Jul28.033744.13313@CSD-NewsHost.Stanford.EDU>
  11. Date: Tue, 28 Jul 1992 08:09:21 GMT
  12. Lines: 20
  13.  
  14. The problem is that the code nested inside the UNLESS is not at 
  15. top-level.  EVAL-WHEN can cause compile-time evaluation only when
  16. it appears at top-level, so the inner EVAL-WHEN in your code doesn't
  17. do anything useful.  Defining forms such as DEFCONSTANT also have
  18. no compile-time effect unless they appear at top-level.
  19.  
  20. A better way to do this kind of conditionalization would be something
  21. like this:
  22.  
  23. (eval-when (:compile-toplevel :load-toplevel)
  24.   (if (fboundp 'foo) (pushnew :foo-feature *features*)))
  25.  
  26. #-:foo-feature
  27. (progn
  28.   ; code to define your own foo goes here.
  29.   )
  30.  
  31. Notice that PROGN does pass "top-level-ness" on to its subforms.
  32.  
  33. -Sandra
  34.