# Namespacing of methods

**URL:** <https://discourse.julialang.org/t/namespacing-of-methods/72677>\
**Category:** Internals & Design\
**Tags:** namespaces\
**Created:** [December 6, 2021, 8:14pm UTC](https://discourse.julialang.org/t/namespacing-of-methods/72677 "2021-12-06T20:14:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 6, 2021, 8:32pm UTC](https://discourse.julialang.org/t/namespacing-of-methods/72677/2 "2021-12-06T20:32:25Z")

</div>

Nice resume, all that seems perfectly correct (and helpful).

I think the way to think about these things is about namespaces.

`import A: func` brings `func` to the namespace where that was executed. If that namespace is `module B`, then `B.func` is available. If inside `module B` you add `export func` now, `func` is available where `using B` was executed.

`using A` will put then `func` into the current namespace if it is exported in `A` (the same thing as above). If that was executed inside `module B`, now `B.func` exists.

`import A` does not bring `A.func` into the namespace, thus if that was executed inside `module B`, there will be no `B.func`.

(I don’t think you can import or export one method but not the other, of the same function. That is one of the reasons type piracy is highly discouraged).

Concerning the “bug”: actually the problem there is that Julia does not complain of a module exporting something that is not defined (it can’t really do that, because the module is parsed sequentially, thus it cannot know if there will be a definition later). A linter could possibly do that. But here the REPL does not seem to try to autocomplete, while `B.<tab>` does (with a stranger name that does not overlap with any other function that is clearer):

```julia
julia> module B
           export foobar
       end
Main.B

julia> foo # tab (nothing appears)

julia> B.foobar # does autocomplete
ERROR: UndefVarError: foobar not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:35
 [2] top-level scope
   @ REPL[2]:1

```

---

_[View the full topic](https://discourse.julialang.org/t/namespacing-of-methods/72677)._
