Ok, will do.<br><br>How about "in long?" Why can't eval bind to an environment that encompasses the lexical closure I made?<br><br>Mike<br><br><div><span class="gmail_quote">On 10/25/07, <b class="gmail_sendername">
Chongkai Zhu</b> <<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Mike J. Bell wrote:<br>> I don't think this is PLT specific, so I apologize if this should be<br>> on a more general scheme list.<br>><br>> I'm interested in adding a generic hook to evaluate a piece of code at
<br>> an arbitrary point in my program. This would be useful for debugging<br>> purposes. For instance:<br>><br>> (let ((x 5))<br>> ;(do a bunch of stuff with x)<br>> (write (eval (read))))<br>>
<br>> Obviously this isn't very useful outside of a loop or other more<br>> complicated idea, but this is just a toy to show the problem. When<br>> (read) runs, I would like to type in something like:<br>>
<br>> (set! x 7)<br>><br>> This doesn't work. The error is that 'x' is unbound. So I tried:<br>> ...<br>> (write (eval (read) (interaction-environment))))<br>><br>> and that didn't work either. It seems like I can't get to the
<br>> environment that contains the lexical closure created by the initial<br>> (let...).<br>><br>> Is there any way around this? I supposed I could write my own (mini)<br>> version of eval, but that seems pretty extreme. How can I get access
<br>> to the lexical environment at the point (eval) is executed so I can<br>> inject arbitrary code?<br><br>In short, you can't. So try some other way to do the debug, say using<br>the debug tool.<br><br>><br>
> Thanks for any tips!!!<br>><br>> Mike<br>><br>> --<br>> Mike J. Bell on gmail<br>> ------------------------------------------------------------------------<br>><br>> _________________________________________________
<br>> For list-related administrative tasks:<br>> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>><br><br></blockquote></div><br><br clear="all">
<br>-- <br>Mike J. Bell on gmail