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