<div dir="ltr"><div dir="ltr">Thanks for the fast reply.<br>One thing I don't understand: 'exp' is bounded without scheme/base. What is so special about the new binding in scheme/base?<br>For example, the following code works fine:<br>
<br><span style="font-family: courier new,monospace;">(define foo</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (lambda (x)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (* x x)))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define foo</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (lambda (b e)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (if (= e 0) 1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (* b (foo b (- e 1))))))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(foo 2 5)</span><br style="font-family: courier new,monospace;">
<br>I bind foo twice with different parameters, but its working!<br></div><br>
<br><br><div class="gmail_quote">On Tue, Mar 8, 2011 at 2:50 PM, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
`scheme/base' provides a binding called `exp', which requires 2<br>
arguments. When the compiler expands your definition, it looks at the<br>
variable reference in the body of the function *before* it binds your<br>
new `exp' definition. Therefore, it uses the `exp' that it has in<br>
scope at that time -- the one from `scheme/base'.<br>
<br>
This is an instance of a general problem with compilation and<br>
expansion at the top-level, and one of the many reasons why it's<br>
better to write programs in modules.<br>
<div><div></div><div class="h5"><br>
On Tue, Mar 8, 2011 at 7:37 AM, Yaron Gonen <<a href="mailto:yaron.gonen@gmail.com">yaron.gonen@gmail.com</a>> wrote:<br>
> Hi,<br>
> (I'm using Dr Scheme version 4.2.2, with language R5RS, and the "Disallow<br>
> redefining" is not checked.)<br>
><br>
> The following code works perfectly:<br>
> (define exp<br>
> (lambda (b e)<br>
> (if (= e 0) 1<br>
> (* b (exp b (- e 1))))))<br>
> (exp 2 5)<br>
><br>
> However, when I include the line (#%require scheme/base), I get an error:<br>
> exp: expects 1 argument, given 2: 2 4<br>
><br>
> How is that possible?<br>
><br>
> Many thanks,<br>
> Yaron<br>
><br>
</div></div>> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
</font></blockquote></div><br></div>