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

From: Alfred Zhong (alfchung02 at gmail.com)
Date: Tue May 14 07:01:51 EDT 2013

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)
            (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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130514/5a9d97a1/attachment.html>

Posted on the users mailing list.