home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / lisp / 2357 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  2.2 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usc!isi.edu!venera.isi.edu!tar
  2. From: tar@ISI.EDU (Thomas A. Russ)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Macros, macroexpansion & the compile-time environment.
  5. Message-ID: <22303@venera.isi.edu>
  6. Date: 1 Sep 92 17:21:00 GMT
  7. Sender: news@isi.edu
  8. Reply-To: tar@isi.edu
  9. Organization: USC-ISI
  10. Lines: 53
  11.  
  12.  
  13. While doing some portability checks for our system, I ran into a
  14. problem in Allegro V4.1 (Sun Sparc).  What happens is the following:
  15.  
  16. We have a package which shadows IF.  It is defined in a file loaded
  17. before we load or compile any of our system:
  18.  
  19. (defpackage "OURS" (:use "COMMON-LISP")
  20.   (:shadow "IF") ...)
  21.  
  22. In another file, we define our own variant of IF:
  23.  
  24.   (in-package "OURS")
  25.  
  26.   (defmacro if (test then &rest else-list)
  27.      (when (null else-list)
  28.        (warn "IF statements should have an else clause"))
  29.      `(COMMON-LISP:if ,test ,then ,@else-list))
  30.  
  31.   ;; Later in the same file, we use if in a different macro, which has
  32.   ;; been abstracted here:
  33.  
  34.   (defmacro other-macro (&rest body-of-macro)
  35.     ;; We do some processing of the body, gory details omitted.
  36.     (dolist (form body-of-macro)
  37.       (if (test-form form)        ;; <==== NOTE the "IF" here
  38.       (do-this form)
  39.           (do-that form)))
  40.     `(some-function ,@args))
  41.  
  42.  
  43. In Allegro v4.1, this second macro will not compile correctly.
  44. Apparently the macro definition of "IF" is not available for use in
  45. the expansion generation code for "OTHER-MACRO", since and undefined
  46. function error occurs.  Since this does not happen in TI Common Lisp,
  47. Macintosh MCL or Lucid v4, I think that this may be a bug in Allegro.
  48. Since it involves what is available in the compile time environment as
  49. well as the environment in which macro expansion and macro expansion
  50. function definition occurs, I thought I would seek advice:
  51.  
  52.     Does the CommonLisp standard require the shadowed definition of
  53.     "IF" to be used in "OTHER-MACRO"?  Or is the standard mute?
  54.  
  55.  
  56. - Tom.
  57.  
  58.  
  59. P.S.:  I know how to fix the problem for Allegro (use
  60.        "common-lisp:if"), I was just curious about the environment issue).
  61. --
  62.  
  63. Thomas A. Russ                                             tar@isi.edu    
  64. USC/ISI, 4676 Admiralty Way, Marina del Rey, CA 90292      (310) 822-1511
  65.