|Arc's eval works by compiling an expression sans lexical environment, then calling mzscheme's eval on the result.|
So, it obviously can't evaluate lexical variables:
(xdef eval (lambda (e)
(eval (ac (ac-denil e) '()))))
Perhaps this is intentional. It's the way Common Lisp's eval works, though at least you can reify the environment
arc> (= x 5)
arc> (eval 'x)
arc> (let x 10 (eval 'x))
arc> (let y 10 (eval 'y))
Error: "reference to undefined identifier: _y"
and use this with evalhook, which takes the environment as an argument
> (setf x 5)
> (eval 'x)
> (let ((x 10)) (eval 'x))
> (let ((x 10)) (the-environment))
#(#(X 10 NIL) NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION)))
It's even the way mzscheme's eval works (to the best of my knowledge), so we can't just do something like
> (let ((x 10)) (evalhook 'x nil nil (the-environment)))
since Scheme's eval still won't know what to do with the lexical variables compiled out by ac.
(xdef eval (lambda (expr env)
(eval (ac (ac-denil expr) (ac-denil env)))))
I've tried hacking various solutions into ac.scm, but my Scheme-fu is pathetic, and I haven't gotten anything working 100%. I suspect there's some relevant mzscheme feature or other, but I'm pretty tired of wrestling with this.
Can anyone help?