A namespace is a set of functions or scripts that can "see" the same objects.
In Julia, namespaces are created by modules.
module is created by
julia> module Foo export g f(x) = x ^ 2; g(x) = x / 2; end Main.Foo
Even what you run in the REPL lives in a module called
This is why the
module that we just created is
Main.Foo (not just
It is a sub-module of
To access the objects inside of
Foo we need to import the module:
# We did not import `Foo`, so we get an error. julia> f(2) ERROR: UndefVarError: f not defined Stacktrace:  top-level scope at REPL:1 # This imports `Foo` julia> using .Foo julia> Foo.f(2) 4
We still cannot just type
Foo did not
Only objects that are exported can be called without the module name as a qualifier.
julia> g(2) 1