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

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!phil
  3. From: phil@Xenon.Stanford.EDU (Phil Stubblefield)
  4. Subject: Re: Help with EVAL-WHEN
  5. Message-ID: <1992Jul28.183237.25456@CSD-NewsHost.Stanford.EDU>
  6. Sender: news@CSD-NewsHost.Stanford.EDU
  7. Organization: Computer Science Department, Stanford University.
  8. References: <1992Jul28.033744.13313@CSD-NewsHost.Stanford.EDU> <1992Jul28.120934.9306@cs.yale.edu>
  9. Date: Tue, 28 Jul 1992 18:32:37 GMT
  10. Lines: 40
  11.  
  12. In article <1992Jul28.120934.9306@cs.yale.edu> loosemore-sandra@CS.YALE.EDU
  13.  (Sandra Loosemore) writes:
  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. Sandra,
  21.  
  22. I think my confusion stems from a misunderstanding of X3J13 action #50, or
  23. DEFINING-MACROS-NON-TOP-LEVEL:ALLOW, if you don't remember off the top of
  24. your head.  :)  I had interpreted the various CLtL/2 references to this vote
  25. to mean that these defining forms would work exactly the same in non-
  26. top-level contexts.  Rereading the top paragraph on p. 84 helped to clarify
  27. that the real issue behind this vote is that the various defining forms
  28. must capture the current lexical environment correctly, although it is
  29. still the case that "certain compile-time side effects of these defining
  30. forms are performed only when the defining forms occur at top level."
  31.  
  32. >A better way to do this kind of conditionalization would be something
  33. >like this:
  34. >
  35. >(eval-when (:compile-toplevel :load-toplevel)
  36. >  (if (fboundp 'foo) (pushnew :foo-feature *features*)))
  37. >
  38. >#-:foo-feature
  39. >(progn
  40. >  ; code to define your own foo goes here.
  41. >  )
  42. >
  43. >Notice that PROGN does pass "top-level-ness" on to its subforms.
  44. >
  45. >-Sandra
  46.  
  47. Thanks much!
  48. -- 
  49.  
  50. Phil Stubblefield                                        (415) 325-7165
  51. Rockwell Palo Alto Laboratory                    phil@rpal.rockwell.com
  52.