[racket] DrRacket and Modules

From: Jos Koot (jos.koot at telefonica.net)
Date: Mon Aug 15 04:56:52 EDT 2011

About (define cons 1). Originally this was not permitted. On my request this
was permitted more than a year ago. The remark in the guide must be a left
over of old times. The reason I asked for this change is the following:
suppose you have a module that imports racket and defines a variable
some-name. Now if racket is extended to export a variable of the same name,
your module would no longer work. It is a matter of scope. It remains
prohibited to import the same variable from two different modules.


From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
On Behalf Of Harry Spier
Sent: lunes, 15 de agosto de 2011 6:02
To: users at racket-lang.org
Subject: [racket] DrRacket and Modules

When I run the following code in DrRacket it behaves somewhat differently
than the documentation says a module should. 

(module m racket
  (define x 10)
  (define cons 1))

The Racket reference says:
One difference between a module and a top-level definition is that a module
can be declared without instantiating its module-level definitions.
Evaluation of a require instantiates (i.e., triggers the instantiation of) a
declared module, which creates variables that correspond to its module-level

For example, given the module declaration
(module m racket
  (define x 10))

the evaluation of (require 'm) creates the variable x and installs 10 as its
value. This x is unrelated to any top-level definition of x.

But when I run the above code, the interactions window shows that x is
defined as 10 even though I don't execute a require statement.

Also the Racket Guide says:
A module-level define can bind only identifiers that are not already bound
within the module. For example, (define cons 1) is a syntax error in a
racket module, since cons is provided by racket. A local define or other
binding forms, however, can give a new local binding for an identifier that
already has a binding; such a binding shadows the existing binding.
But DrRacket doesn't give an error for (define cons 1) and the interactions
window shows cons has been redefined as 1.

Could someone explain why the behavior in DrRacket differs in these cases
from the documentation.

Thanks in advance,
Harry Spier

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110815/bd8d7add/attachment.html>

Posted on the users mailing list.