[racket] Different behavior when using (#%require scheme/base)
Thanks for the fast reply.
One thing I don't understand: 'exp' is bounded without scheme/base. What is
so special about the new binding in scheme/base?
For example, the following code works fine:
(define foo
(lambda (x)
(* x x)))
(define foo
(lambda (b e)
(if (= e 0) 1
(* b (foo b (- e 1))))))
(foo 2 5)
I bind foo twice with different parameters, but its working!
On Tue, Mar 8, 2011 at 2:50 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu>wrote:
> `scheme/base' provides a binding called `exp', which requires 2
> arguments. When the compiler expands your definition, it looks at the
> variable reference in the body of the function *before* it binds your
> new `exp' definition. Therefore, it uses the `exp' that it has in
> scope at that time -- the one from `scheme/base'.
>
> This is an instance of a general problem with compilation and
> expansion at the top-level, and one of the many reasons why it's
> better to write programs in modules.
>
> On Tue, Mar 8, 2011 at 7:37 AM, Yaron Gonen <yaron.gonen at gmail.com> wrote:
> > Hi,
> > (I'm using Dr Scheme version 4.2.2, with language R5RS, and the "Disallow
> > redefining" is not checked.)
> >
> > The following code works perfectly:
> > (define exp
> > (lambda (b e)
> > (if (= e 0) 1
> > (* b (exp b (- e 1))))))
> > (exp 2 5)
> >
> > However, when I include the line (#%require scheme/base), I get an error:
> > exp: expects 1 argument, given 2: 2 4
> >
> > How is that possible?
> >
> > Many thanks,
> > Yaron
> >
> > _________________________________________________
> > For list-related administrative tasks:
> > http://lists.racket-lang.org/listinfo/users
> >
>
>
>
> --
> sam th
> samth at ccs.neu.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110308/335aaa95/attachment.html>