I don't think this is PLT specific, so I apologize if this should be on a more general scheme list.<br><br>I'm interested in adding a generic hook to evaluate a piece of code at an arbitrary point in my program. This would be useful for debugging 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 complicated idea, but this is just a toy to show the problem. When (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 environment that contains the lexical closure created by the initial (let...).
<br><br>Is there any way around this? I supposed I could write my own (mini) version of eval, but that seems pretty extreme. How can I get access to the lexical environment at the point (eval) is executed so I can inject arbitrary code?
<br><br>Thanks for any tips!!!<br><br>Mike<br clear="all"><br>-- <br>Mike J. Bell on gmail