Andy Wingo <[email protected]> writes:
> On Wed 14 Dec 2011 00:00, Noah Lavine <[email protected]> writes:
>> I haven't really been contributing to this thread, so please take my
>> opinion with a grain of salt. But it does appear to me that we should
>> support capturing a lexical environment, as Mark and David describe.
>>
>> So I took a look at ice-9/eval.scm....
>
> The details of the interpreter's implementation are not public, I'm
> afraid. The interpreter does its job, but not quickly, and any change
> to make it better would involve a change to the environment
> representation.
I agree that the returned "lexical environment object" should opaque.
Probably the only operation that needs this object is "local-eval",
though I'm not sure there's any disadvantage to printing it in
human-readable form for debugging purposes. It might also be nice to
provide a procedure that converts it into an alist of some sort, but
that's not strictly needed.
I believe this would give us plenty of freedom to change the environment
representation in the future, no?
> Anyway, it's looking in the wrong place. There is a compiler too.
The most obvious implementation of (capture-lexical-environment) would
inhibit compilation of any top-level form that contains it. Therefore,
the only thing the compiler would need to do is detect the presence of
(capture-lexical-environment), and in that case, abort compilation of
the entire top-level form. I guess such a form should be "compiled"
simply as a call to the evaluator with the entire top-level form as its
argument. This would all happen after macro expansion, of course.
Does this make sense?
Mark