🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.scheme.c
2 messages
2 total messages Started by Kardan Kaveh Fri, 22 Jan 1993 08:21
macro problem
#197
Author: Kardan Kaveh
Date: Fri, 22 Jan 1993 08:21
23 lines
875 bytes
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

Also, I can't seem to find any documentation on macros in the info files.

Thanks,

Kaveh



-- 
------------
Kaveh Kardan                                       kaveh@taarna.UUCP
Systeme Taarna                                     kardank@eole.umontreal.qc.ca
Montreal Quebec Canada                             (514)844-8448
Re: macro problem
#198
Author: Guillermo J. Rozas
Date: Fri, 22 Jan 1993 16:55
50 lines
2340 bytes
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads