Hi Mark, On Sun 08 Jan 2012 21:39, Mark H Weaver <m...@netris.org> writes:
> Andy Wingo <wi...@pobox.com> writes: >> I guess it's not clear to me why you would want to force expression >> context. > > If we allow definitions, then your nice equivalence > > <form> == (local-eval '<form> (the-environment)) > > no longer holds. Also, the user cannot use the simple mental model of > imagining that <form> had been put in place of (the-environment). > > For example: > > (let ((x 1)) > (define (get-x) x) > (begin > (define x 2) > (get-x))) > => 2 > > is _not_ equivalent to: > > (let ((x 1)) > (define (get-x) x) > (local-eval '(begin > (define x 2) > (get-x)) > (the-environment))) > => 1 > > The only way I see to achieve your equivalence is to constrain <form> to > be an expression. Ahh, yes indeed. Thanks for the example. Another (less clear) way to say this would be to note that it's not possibly to incrementally build up a set of recursive bindings. Or, another try: local-eval cannot be allowed to affect the resolution of variables already in the environment. Therefore it does not capture an open set of mutually recursive bindings. I'm not doing very well at describing it, but your example was very good. What about the-environment outside of a lexical contour, though? Does that permit definitions? Should it? Andy -- http://wingolog.org/