Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonster/reexport.jl
Julia macro for re-exporting one module from another
https://github.com/simonster/reexport.jl
julia module reexport
Last synced: about 16 hours ago
JSON representation
Julia macro for re-exporting one module from another
- Host: GitHub
- URL: https://github.com/simonster/reexport.jl
- Owner: simonster
- License: other
- Created: 2014-04-11T02:19:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-09-09T16:54:09.000Z (over 2 years ago)
- Last Synced: 2024-12-07T16:03:37.855Z (16 days ago)
- Topics: julia, module, reexport
- Language: Julia
- Size: 31.3 KB
- Stars: 164
- Watchers: 6
- Forks: 19
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Reexport
[![Build status](https://github.com/simonster/Reexport.jl/workflows/CI/badge.svg)](https://github.com/simonster/Reexport.jl/actions?query=workflow%3ACI+branch%3Amaster)
## Introduction
Maybe you have a module `X` that depends on module `Y` and you want `using X` to pull in all of the symbols from `Y`. Maybe you have an outer module `A` with an inner module `B`, and you want to export all of the symbols in `B` from `A`. It would be nice to have this functionality built into Julia, but we have yet to reach an agreement on what it should look like (see [JuliaLang/julia#1986](https://github.com/JuliaLang/julia/issues/1986)). This short macro is a stopgap we have a better solution.
## Usage
`@reexport using ` calls `using ` and also re-exports their symbols:
```julia
module Y
...
endmodule Z
...
endmodule X
using Reexport
@reexport using Y
# all of Y's exported symbols available here
@reexport using Z: x, y
# Z's x and y symbols available here
endusing X
# all of Y's exported symbols and Z's x and y also available here
````@reexport import .` or `@reexport import : ` exports `` from `` after importing it.
```julia
module Y
...
endmodule Z
...
endmodule X
using Reexport
@reexport import Y
# Only `Y` itself is available here
@reexport import Z: x, y
# Z's x and y symbols available here
endusing X
# Y (but not its exported names) and Z's x and y are available here.
````@reexport module ... end` defines `module ` and also re-exports its symbols:
```julia
module A
using Reexport
@reexport module B
...
end
# all of B's exported symbols available here
endusing A
# all of B's exported symbols available here
````@reexport @another_macro ` first expands `@another_macro` on the expression, making `@reexport` with other macros.
`@reexport begin ... end` will apply the reexport macro to every expression in the block.