[racket-dev] make-empty-namespace vs make-base-empty-namespace; ie attaching racket/base does other "stuff"

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Mon Apr 28 16:38:24 EDT 2014

Motivated by some recent email threads, I decided to better understand
how Racket namespaces work by re-reading some docs but I got confused.

Paraphrasing the examples from this part of the guide:
http://docs.racket-lang.org/guide/mk-namespace.html

the following example fails because the module registry in the
namespace is empty:

(parameterize ([current-namespace (make-empty-namespace)])
  (namespace-require "m.rkt")) ; error

But the example works if make-base-empty-namespace is used instead:

(parameterize ([current-namespace (make-base-empty-namespace)])
  (namespace-require "m.rkt")) ; works

(Assume the contents of m.rkt is "#lang racket/base" with nothing else.)

According to the docs, make-base-empty-namespace "attaches"
racket/base but why does this make "m.rkt" suddenly "available"? There
seems to be an unexplained gap between to the two examples. (Adding to
my confusion is that (module-declared? "m.rkt") evaluates to false,
even in the 2nd case.)

With help from Vincent, we investigated and speculate that perhaps
attaching racket/base also runs "boot" from '#%boot, which populates
current-module-name-resolver, but could not conclude anything
definitively. Can someone explain what's happening?

Posted on the dev mailing list.