[plt-scheme] eval & syntax-rules

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Apr 20 12:16:22 EDT 2010

This expression:

 (let ([t 2])
     (eval t (make-base-namespace)))

is equivalent to this one:

  (eval 2 (make-base-namespace))

I think you probably meant to write this:

 (let ([t 2])
     (eval 't (make-base-namespace)))

Eval is not what you think it is, I'd say. It isn't like ruby's eval,
for example.  There are lots of discussions of this in the mail
archives for this list and some of them may even have made it into the
Guide.

Robby

On Tue, Apr 20, 2010 at 11:13 AM, 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
> 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
> Thanks.
> ________________________________
> Gardez le contact. Obtenez la version mobile de Messenger ici
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.