home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!zurich.ai.mit.edu!gjr
- From: gjr@zurich.ai.mit.edu (Guillermo J. Rozas)
- Newsgroups: comp.lang.scheme.c
- Subject: Re: macro problem
- Message-ID: <GJR.93Jan22085538@chamarti.ai.mit.edu>
- Date: 22 Jan 93 16:55:38 GMT
- References: <1993Jan22.082118.21781@cc.umontreal.ca>
- Reply-To: gjr@zurich.ai.mit.edu
- Distribution: inet
- Organization: M.I.T. Artificial Intelligence Lab.
- Lines: 50
- NNTP-Posting-Host: chamartin.ai.mit.edu
- In-reply-to: kardank@ERE.UMontreal.CA's message of 22 Jan 93 08:21:18 GMT
-
- In article <1993Jan22.082118.21781@cc.umontreal.ca> kardank@ERE.UMontreal.CA (Kardan Kaveh) writes:
-
- |
- | From: kardank@ERE.UMontreal.CA (Kardan Kaveh)
- | Newsgroups: comp.lang.scheme.c
- | Date: 22 Jan 93 08:21:18 GMT
- |
- | What's wrong with the following? MIT Scheme 7.2 complains f1 is unbound.
- |
- | (define (f1 x) (* x x))
- |
- | (define-macro (m1 y) `(+ 2 ,(f1 y)))
- |
- | (m1 3)
- |
- | ;Unbound variable: f1
- |
-
- The environment where the macro expander procedure
- (i.e. (lambda (y) `(+ ... )) ) is closed is _not_ the top level
- environment where F1 is bound. It is a separate environment.
-
- This may seem like a strange decision, but imagine that F1, M1, and a
- use of M1 are in some file that is to be compiled. At the time of
- compilation, M1 needs to be expanded, but the expansion requires the
- binding for F1 that will not exist until run time. Since clearly,
- when compiling, the macro expander cannot be closed in the runtime
- environment, we decided to make a special environment for macro
- expanders to be closed, and this is done consistently when compiling
- and simply interacting.
-
- The environment where macro expanders is closed is the value of the
- global variable SYNTAXER/DEFAULT-ENVIRONMENT.
- In your init file, you can include
-
- (set! syntaxer/default-environment user-initial-environment)
-
- or some such, and then it will have the behavior that you want when
- interacting.
-
- |
- | Also, I can't seem to find any documentation on macros in the info files.
- |
-
- Correct. There is a very short document giving an overview (and
- pointing out some gotchas) but it is not integrated into the info
- structure.
-
- You can get it from altdorf.ai.mit.edu:archive/scheme-7.2/macros.txt
- by anonymous ftp.
-