home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usc!isi.edu!venera.isi.edu!tar
- From: tar@ISI.EDU (Thomas A. Russ)
- Newsgroups: comp.lang.lisp
- Subject: Macros, macroexpansion & the compile-time environment.
- Message-ID: <22303@venera.isi.edu>
- Date: 1 Sep 92 17:21:00 GMT
- Sender: news@isi.edu
- Reply-To: tar@isi.edu
- Organization: USC-ISI
- Lines: 53
-
-
- While doing some portability checks for our system, I ran into a
- problem in Allegro V4.1 (Sun Sparc). What happens is the following:
-
- We have a package which shadows IF. It is defined in a file loaded
- before we load or compile any of our system:
-
- (defpackage "OURS" (:use "COMMON-LISP")
- (:shadow "IF") ...)
-
- In another file, we define our own variant of IF:
-
- (in-package "OURS")
-
- (defmacro if (test then &rest else-list)
- (when (null else-list)
- (warn "IF statements should have an else clause"))
- `(COMMON-LISP:if ,test ,then ,@else-list))
-
- ;; Later in the same file, we use if in a different macro, which has
- ;; been abstracted here:
-
- (defmacro other-macro (&rest body-of-macro)
- ;; We do some processing of the body, gory details omitted.
- (dolist (form body-of-macro)
- (if (test-form form) ;; <==== NOTE the "IF" here
- (do-this form)
- (do-that form)))
- `(some-function ,@args))
-
-
- In Allegro v4.1, this second macro will not compile correctly.
- Apparently the macro definition of "IF" is not available for use in
- the expansion generation code for "OTHER-MACRO", since and undefined
- function error occurs. Since this does not happen in TI Common Lisp,
- Macintosh MCL or Lucid v4, I think that this may be a bug in Allegro.
- Since it involves what is available in the compile time environment as
- well as the environment in which macro expansion and macro expansion
- function definition occurs, I thought I would seek advice:
-
- Does the CommonLisp standard require the shadowed definition of
- "IF" to be used in "OTHER-MACRO"? Or is the standard mute?
-
-
- - Tom.
-
-
- P.S.: I know how to fix the problem for Allegro (use
- "common-lisp:if"), I was just curious about the environment issue).
- --
-
- Thomas A. Russ tar@isi.edu
- USC/ISI, 4676 Admiralty Way, Marina del Rey, CA 90292 (310) 822-1511
-