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 definitions.

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
                                          
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to