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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Apr 29 16:52:15 EDT 2014

At Tue, 29 Apr 2014 15:15:44 -0400, Stephen Chang wrote:
> I guess I'm still unsatisfied because it still feels like there's a
> gap between the namespace "model" as presented by the docs and what
> actually happens. For example, the docs give me the impression that
> you can't require a module unless it's already declared [1].
> [...]
> [1]: 
> http://docs.racket-lang.org/reference/eval-model.html#%28part._module-eval-model
> %29

I see what you mean. It's true that `require` instantiates a module
that is declared, but `require` may also resolve a module path, and the
resolution of a module path can cause a module to be declared.

That is,

 (require "m.rkt")

first resolves "m.rkt", which normally has the side effect of loading a
file that declares a module, and then `require` instantiates that
declared module.

> In general, I feel that certain terms, eg, namespace, attach, declare,
> instantiate, should have precise technical meanings but are used
> imprecisely in the docs so that I can't form a proper mental model.

While there's lots of room for mistakes and incompleteness, those words
are at least intended to have specific technical meanings. My guess is
that the problem is more often incompleteness (as the above example
illustrates) than misuse of the words.

> For example, is possible to say "makes it possible to load "m.rkt""
> using the terminology of the docs? 

I don't think there's a single word for that, because it depends on so
many things: "m.rkt" being present relative to the current directory,
the current namespace having the necessary module declarations for the
imports of the module in "m.rkt", a module-name resolver that works, an
eval handler that works, and so on.

You might mean something more specific where we have or still need a
word, though; I'm not sure.

> Is there ever a state where "m.rkt"
> is "declared" but not "instantiated"?

Yes. Resolving the module path "m.rkt" will cause the declaration to be
loaded, but resolving a module path does not instantiate a module.

Similarly, in a REPL, just

 (module m racket/base)

declares the module 'm without instantiating it.

> I'm willing to work to improve these parts of the docs to make things
> more consistent (if others agree that improvements are needed).

Documentation improvements are definitely welcome.


Posted on the dev mailing list.