[plt-scheme] eval & syntax-rules

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Tue Apr 20 12:17:49 EDT 2010

On Tue, Apr 20, 2010 at 12:13 PM, Skeptic . <skeptic2000 at hotmail.com> wrote:
>
> Hi,
> Why something like this works :
> #lang scheme
> (define t 9)
> (let ([t 2])
>     (eval t (make-base-namespace)))
> -> 2


This is the same as:

(eval 2 (make-base-namespace))

> but not something like this :
> #lang scheme
> (define a 4)
> (define b 5)
> (define c 6)
> (define-syntax test
>   (syntax-rules ()
>     [(test id ...)
>      (eval '(id ...) (make-base-namespace))]))
> (test a b c)
> ->  reference to a unidentified identifier : a

This is like (eval (a b c) (make-base-namespace)) (which would be an
error even in an appropriate namespace, since 4 is not a function).
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.