[racket-dev] Top level is hopeless or bug?

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Sep 18 02:32:13 EDT 2012

Three hours ago, Asumu Takikawa wrote:
> -> (module foo racket (define x 0) (provide x))
> [...]
> -> (module foo racket (module* bar #f (define x 1) (provide x)))
> -> x
> ; readline-input:4:0: link: module mismatch;
> ;  possibly, bytecode file needs re-compile because dependencies

This looks like a bad error message, and/or maybe something doesn't
assume that that internal links can change? -- Possibly similar to
this:

  -> (module foo racket (define x 0))
  -> (module foo racket (provide x))
  ; stdin:2:28: module: provided identifier not defined or imported for phase 0
  ;   at: x



> This is also interesting:
> 
> Welcome to Racket v5.3.0.24.
> -> (module foo racket (define x 0) (provide x))
> [...]
> -> (module foo racket (define x 1) (provide x))

This is because the module is already instantiated, so you're trying
to mutate a constant.  For example, this works:

  -> (module foo racket (define x 0) (provide x))
  -> (module foo racket (define x 1) (provide x))
  -> (require 'foo)

And if you want to play such games:

  -> (compile-enforce-module-constants #f)
  -> (module foo racket (define x 0) (provide x))
  -> (require 'foo)
  -> x
  0
  -> (module foo racket (define x 1) (provide x))
  -> x
  1

(Or use `enter!' or xrepl etc...)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.