[racket] Redefinitions in modules

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Jan 10 16:09:23 EST 2012

It isn't redefined, it is shadowed-- the definitions in a module are
in one lexical scope lower than the module position. Racket's module
system doesn't allow redefinition.

That is, the first example has more in common with this expression

 (let ([+ -])
   (+ 7 2))

than it does with the second one.

The second one is more like:

  (let ([+ 5]
        [+ -])
    ...)

with two bindings introduced at the same scope.

Robby

On Tue, Jan 10, 2012 at 2:51 PM, Gustavo Massaccesi <gustavo at oma.org.ar> wrote:
> I tried the following programs in DrRacket  5.2
>
> ;--- start
> #lang racket/base
> (define + -)
> (+ 7 2)
> ;--- end
> Result:
> 5
> ;---
>
>
> ;--- start
> #lang racket/base
> (require (only-in racket/base +))
> (define + -)
> (+ 7 2)
> ;--- end
> Result:
> [error] module: identifier is already imported in: +
> ;---
>
>
> In the first example the function + is redefined. I expected to get an
> error in both programs. I’m not sure if this is a bug or a feature.
>
> (And I couldn’t find in the documentation which is the expected behavior.)
>
> Gustavo
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.