Skip to content

Commit

Permalink
update note on package extensions (JuliaLang#3451)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored May 4, 2023
1 parent a2e429e commit 6f02014
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/src/creating-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,16 @@ If one considers `PlottingContourExt` as a completely separate package, it could
However, for extensions, it is ok to assume that the extension owns the methods in its parent package.
In fact, this form of type piracy is one of the most standard use cases for extensions.

An extension will only be loaded if the extension dependencies are loaded from the same environment or environments higher in the environment stack than the package itself.
!!! note
An extension will only be loaded if the extension dependencies are loaded from the same environment or environments
higher in the environment stack than the package itself. This means that you can load a package having an extension
from your main/default environment, load another package required for the dependency from your active project, and
get the functionality from the extension. The other way round does not work, i.e., if you load a package having
an extension from a project environment and then load the package required for the extension from you main/default
environment, the extension will not be loaded. This is different from the behavior of Requires.jl where the
conditional code is evaluated no matter from what environment the "extension dependency" is loaded.



!!! compat
Often you will put the extension dependencies into the `test` target so they are loaded when running e.g. `Pkg.test()`. On earlier Julia versions
Expand Down

0 comments on commit 6f02014

Please sign in to comment.