This works because you are calling (eval-string-with-1 "abc") from outside the module - but it doesn't when the function is called from the inside the module. For instance :<br><br>(module foo mzscheme<br> (define (abc x)
<br> (display "foo")<br> (newline))<br> <br> (define (eval-string-with-1 string)<br> ((eval (string->symbol string)) 1))<br> <br> <br> (eval-string-with-1 "abc")<br> <br> (provide eval-string-with-1
<br> abc))<br><br>(require foo)<br><br>Doesn't work. And that's what I need to do :/<br><br><div><span class="gmail_quote">On 6/23/07, <b class="gmail_sendername">Richard Cleis</b> <<a href="mailto:rcleis@mac.com">
rcleis@mac.com</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;"><div style="">A workaround depends on what you are trying to do. For example, providing a function to evaluate a string works, but you also have to provide any function you intend to use.
<div><br></div><div>(module foo mzscheme</div><span class="q"><div> (define (abc x)</div><div> (display "foo")</div><div> (newline))</div><div> </div></span><div> (define (eval-string-with-1 string)</div>
<div> ((eval (string->symbol string)) 1))</div><div> </div><div> (provide eval-string-with-1</div><div> abc)</div><div> )</div><div><br></div><div>(require foo)</div><div><br></div><div>(eval-string-with-1 "abc")
</div><div><br></div><div>rac</div><div><br></div><div><br></div><div><br></div><div><br><div><div><span class="e" id="q_1135963369ec671a_3"><div>On Jun 23, 2007, at 8:56 AM, Jean-Pierre Lozi wrote:</div><br></span></div>
<blockquote type="cite"><div><span class="e" id="q_1135963369ec671a_5">Hi all,<br><br>How can I use eval in a module definition? For instance, <br><br>(define (abc x)<br> (display "foo")<br> (newline))<br><br>((eval (string->symbol "abc")) 1)
<br><br>works, whereas<br><br> (module foo mzxcheme<br> (define (abc x)<br> (display "foo")<br> (newline))<br> <br> ((eval (string->symbol "abc")) 1))<br><br>(require foo)<br><br>doesn't. Eval appears too look for the abc function in the global namespace. Does anyone know a workaround?
<br><br>Thanks,<br><br clear="all"> <br>-- <br>Jean-Pierre Lozi<br><a href="http://www.lozi.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.lozi.org</a><br>mailto:<a href="mailto:jean-pierre@lozi.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
jean-pierre@lozi.org</a></span></div><div style="margin: 0px;">_________________________________________________</div><div style="margin: 0px;"><span> </span>For list-related administrative tasks:</div><div style="margin: 0px;">
<span> </span><a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a></div> </blockquote>
</div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Jean-Pierre Lozi<br><a href="http://www.lozi.org">http://www.lozi.org</a><br>mailto:<a href="mailto:jean-pierre@lozi.org">jean-pierre@lozi.org</a>