You can't access internal defines in an eval, just as you can't access the lexical variable "a".
To get around this you could use set! instead to "define" the variables at toplevel. (let ((a 1)) (set! inc (lambda () (set! a (+ 1 a)) (print a))) (set! runTwice (lambda (op) (op) (op))) (eval '(runTwice inc))) (inc) ;; prints: 2 3 4 Notice `inc` is accessible outside the `let` here. Otherwise you have to use something like the currently nonfunctional `environments` egg. On Jul 2, 2013, at 2:26 PM, "Daniel Ajoy" <da.a...@gmail.com> wrote: > Hi, > > Both this > > (let ((a 1) ) > (define (inc) > (set! a (+ 1 a ) ) ) > (define (runTwice op ) > (op) > (op) ) > (eval '(runTwice inc ) ) > ) > > and this > > (let* ((a 1) ) > (define (inc) > (set! a (+ 1 a ) ) ) > (define (runTwice op ) > (op) > (op) ) > (eval '(runTwice inc ) ) > ) > > Give me the error: > > Error: unbound variable: runTwice > > I'm defining runTwice right before running the eval. What am I not > understanding? > > Daniel > > _______________________________________________ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users