[racket] eval function works at REPL but not in file

From: Alfred Zhong (alfchung02 at gmail.com)
Date: Tue May 14 12:35:00 EDT 2013

Thanks a lot, Matthew! That works!


On Tue, May 14, 2013 at 8:06 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> Hi Alfred,
>
> See
>
>   http://docs.racket-lang.org/guide/eval.html#(part._namespaces)
>
> Matthew
>
> At Tue, 14 May 2013 07:01:51 -0400, Alfred Zhong wrote:
> > Hi Racket experts,
> >
> > I am reading SICP and trying this piece of code using Racke:
> >
> > (define (definition-value exp)
> >     (if (symbol? (cadr exp))
> >         (caddr exp)
> >           (make-lambda
> >             (cdadr exp) ; formal parameters
> >                (cddr exp)  ; body
> >         )
> >     )
> > )
> >
> > (define (make-lambda parameters body)
> >     (cons 'lambda (cons parameters body))
> > )
> >
> > (  (eval  (definition-value '(define (double x) (+ x x))) ) 10)
> >
> > In REPL, it return 20 with no problem.
> >
> > However, if I put it into a file and use racket command to run it (with
> > #lang scheme in the file)
> >
> > it complains:
> > compile: unbound identifier (and no #%app syntax transformer is bound)
> at:
> > lambda in: (lambda (x) (+ x x))
> >
> > Do you have any idea what happened there? How can I solve this problem?
> >
> > Thanks,
> > Alfred
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130514/bd838a79/attachment.html>

Posted on the users mailing list.