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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 14 08:06:10 EDT 2013

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

Posted on the users mailing list.