[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] macro question

From: Peter Keller
Subject: [Chicken-users] macro question
Date: Thu, 12 Sep 2002 21:25:10 -0500
User-agent: Mutt/1.2i


I have a question about hygienic R5RS macros:

Suppose I do this:

(define-syntax testcase
    (syntax-rules ()
    ((testcase clauses ...)
        (let ((d 42))
            (cond ((not (and (begin clauses ...)))
                (print d)))))))

Now, what I want to do is this(don't critique what I it is I am actually
am doing here since it is a made up example):

(testcase #t (set! d 22) #f)

Now, what happens is I get 42 from the above call, not 22.

What I really wanted was for the set! to take effect in the let expression
and affect that d, not some other d in top level, which it will happily do.
Unfortunately, I think this IS the definition of hygienic. :(

Is there anyway I can make this work, and still use hygienic macros?

It'd be nice if you could taint variables with a "non-hygenic" option
so they can be modified with code that the macro expands. Non-tainted
variables would be considered hygienic always and that would be the default.



as an aside: (set! d 22) as the first thing in the interpreter will act just
like define, which my R5RS manual says is wrong, it should fail with an 
unbound variable error if the variable had not been defined previously.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]