[racket-dev] make-empty-namespace vs make-base-empty-namespace; ie attaching racket/base does other "stuff"
Extra bit of information, this works too:
#lang racket
(define ns (make-empty-namespace))
(namespace-attach-module (current-namespace) ''#%builtin ns)
(parameterize ([current-namespace ns])
(namespace-require "m.rkt"))
But replacing ''#%builtin with ''#%kernel or ''#%boot doesn't. Replacing
it with 'racket/base (to end up with the equivalent of
`make-base-empty-namespace') does work.
Vincent
At Mon, 28 Apr 2014 16:38:24 -0400,
Stephen Chang wrote:
>
> 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?
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev