https://github.com/tkf/indirectimports.jl
Import and extend packages without importing them
https://github.com/tkf/indirectimports.jl
Last synced: 9 months ago
JSON representation
Import and extend packages without importing them
- Host: GitHub
- URL: https://github.com/tkf/indirectimports.jl
- Owner: tkf
- License: mit
- Created: 2019-04-27T06:15:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-10T08:45:56.000Z (almost 6 years ago)
- Last Synced: 2025-03-27T14:53:35.350Z (10 months ago)
- Language: Julia
- Homepage: https://tkf.github.io/IndirectImports.jl/dev/
- Size: 88.9 KB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IndirectImports
[](https://tkf.github.io/IndirectImports.jl/stable)
[](https://tkf.github.io/IndirectImports.jl/dev)

[](https://travis-ci.com/tkf/IndirectImports.jl)
[](https://codecov.io/gh/tkf/IndirectImports.jl)
[](https://coveralls.io/github/tkf/IndirectImports.jl?branch=master)
IndirectImports.jl lets Julia packages call and extend (a special type
of) functions without importing the package defining them. This is
useful for managing optional dependencies.
* Compared to Requires.jl, IndirectImports.jl's approach is more
static and there is no run-time `eval` hence more compiler friendly.
However, unlike Requires.jl, both upstream and downstream packages
need to rely on IndirectImports.jl API.
* Compared to "XBase.jl" approach, IndirectImports.jl is more flexible
in the sense that you don't need to create an extra package and keep
it in sync with the "implementation" package(s). However, unlike
"XBase.jl" approach, IndirectImports.jl is usable only for
functions, not for types.
## Example
```julia
# MyPlot/src/MyPlot.jl
module MyPlot
using IndirectImports
@indirect function plot end # declare an "indirect function"
@indirect function plot(x) # optional
# generic implementation
end
end
# MyDataFrames/src/MyDataFrames.jl
module MyDataFrames
using IndirectImports
@indirect import MyPlot # this does not actually load MyPlot.jl
# you can extend indirect functions
@indirect function MyPlot.plot(df::MyDataFrame)
# you can call indirect functions
MyPlot.plot(df.columns)
end
end
```
You can install it with `]add IndirectImports`. See more details in
the [documentation](https://tkf.github.io/IndirectImports.jl/dev/).