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
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