# Is Julia able to export a module as another (aliased) name?

**URL:** https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814
**Category:** General Usage
**Tags:** question, package, development
**Created:** [November 7, 2019, 2:33am UTC](https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814 "2019-11-07T02:33:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [November 7, 2019, 2:33am UTC](https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814/1 "2019-11-07T02:33:38Z")

</div>

I am not the author of [`Yao.jl`](https://github.com/QuantumBFS/Yao.jl). I just want to use it as an example. The [source code of `Yao.jl`](https://github.com/QuantumBFS/Yao.jl/blob/master/src/Yao.jl) is just one simple thing: reexport things defined in its sub-packages.

```julia
using Reexport
@reexport using YaoBase, YaoArrayRegister, YaoBlocks, YaoSym

```

So, am I able to do

```julia
@reexportas YaoArrayRegister ArrayRegister

```

and when users load `Yao`, they can access things defined in `YaoArrayRegister` by `Yao.ArrayRegister`.

I want this feature because I also have a collection of sub-packages like `Yao`, e.g.,

```julia
using AVeryLongNamespace, AVeryLongNamespaceBase, AVeryLongNamespaceParsers

```

Can I just do

```julia
using AVeryLongNamespace
AVeryLongNamespace.Base.something
AVeryLongNamespace.Parsers.anotherthing

```

One way to do this I think is to define a `Base.jl` and `Parsers.jl` in `AVeryLongNamespace` module, and reexport them respectively.

---

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [November 7, 2019, 2:41am UTC](https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814/2 "2019-11-07T02:41:11Z")

</div>

I just found another question: [Package Aliases?](https://discourse.julialang.org/t/package-aliases/29334).

They introduce [`ImportMacros.jl`](https://github.com/fredrikekre/ImportMacros.jl) there.

I guess what I need to do is

```julia
module AVeryLongNamespace
using ImportMacros
@import AVeryLongNamespaceBase as ABase
@import AVeryLongNamespaceParsers as Parsers

export ABase, Parsers
end

```

It is good that [`ImportMacros.jl`](https://github.com/fredrikekre/ImportMacros.jl) create aliases of sub-packages, but it does not have the function of `Reexport`: reexporting symbols.

```julia
julia> using AVeryLongNamespace

julia> names(AVeryLongNamespace)
3-element Array{Symbol,1}:
 :ABase
 :Parsers
 :AVeryLongNamespace

```

However, when using `Reexport`, it also brings sub-packages into scope:

```julia
module AVeryLongNamespace
using Reexport
@reexport AVeryLongNamespaceBase
@reexport AVeryLongNamespaceParsers
end

```

```julia
julia> using AVeryLongNamespace

julia> names(AVeryLongNamespace)
5-element Array{Symbol,1}:
:something
:anotherthing
:AVeryLongNamespace
:AVeryLongNamespaceBase
:AVeryLongNamespaceParsers

```

Can I take the advatanges of both packages to let `names(AVeryLongNamespace)` to be

```julia
julia> names(AVeryLongNamespace)
5-element Array{Symbol,1}:
:something
:anotherthing
:AVeryLongNamespace
:Base
:Parsers

```

I understand it might be tricky to do this, but I just want to know is there any possibility.
