home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp
- Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!phil
- From: phil@Xenon.Stanford.EDU (Phil Stubblefield)
- Subject: Re: Help with EVAL-WHEN
- Message-ID: <1992Jul28.183237.25456@CSD-NewsHost.Stanford.EDU>
- Sender: news@CSD-NewsHost.Stanford.EDU
- Organization: Computer Science Department, Stanford University.
- References: <1992Jul28.033744.13313@CSD-NewsHost.Stanford.EDU> <1992Jul28.120934.9306@cs.yale.edu>
- Date: Tue, 28 Jul 1992 18:32:37 GMT
- Lines: 40
-
- In article <1992Jul28.120934.9306@cs.yale.edu> loosemore-sandra@CS.YALE.EDU
- (Sandra Loosemore) writes:
- >The problem is that the code nested inside the UNLESS is not at
- >top-level. EVAL-WHEN can cause compile-time evaluation only when
- >it appears at top-level, so the inner EVAL-WHEN in your code doesn't
- >do anything useful. Defining forms such as DEFCONSTANT also have
- >no compile-time effect unless they appear at top-level.
-
- Sandra,
-
- I think my confusion stems from a misunderstanding of X3J13 action #50, or
- DEFINING-MACROS-NON-TOP-LEVEL:ALLOW, if you don't remember off the top of
- your head. :) I had interpreted the various CLtL/2 references to this vote
- to mean that these defining forms would work exactly the same in non-
- top-level contexts. Rereading the top paragraph on p. 84 helped to clarify
- that the real issue behind this vote is that the various defining forms
- must capture the current lexical environment correctly, although it is
- still the case that "certain compile-time side effects of these defining
- forms are performed only when the defining forms occur at top level."
-
- >A better way to do this kind of conditionalization would be something
- >like this:
- >
- >(eval-when (:compile-toplevel :load-toplevel)
- > (if (fboundp 'foo) (pushnew :foo-feature *features*)))
- >
- >#-:foo-feature
- >(progn
- > ; code to define your own foo goes here.
- > )
- >
- >Notice that PROGN does pass "top-level-ness" on to its subforms.
- >
- >-Sandra
-
- Thanks much!
- --
-
- Phil Stubblefield (415) 325-7165
- Rockwell Palo Alto Laboratory phil@rpal.rockwell.com
-