The introduction in the
Pkg documentation makes me think that
extensions is just like a built-in implementation of
@require. But, after some initial attempt, I realized that they are not substitutes.
To be concrete, suppose I have a file that used to be handled by
@require and is only loaded when package
A is used. The file simply export an additional object when a package is loaded. To turn it into an extension, I wrap the content into a module and the file now looks like this:
module Attempt export AdditionalObj struct AdditionalObj end end
Now I put
Attempt into the
extensions segment of
Project.toml. I got
julia> Attempt ERROR: UndefVarError: `Attempt` not defined julia> AdditionalObj ERROR: UndefVarError: `AdditionalObj` not defined
extensions not supposed to be used for defining new objects that need to be exported? So, they are only used to add additional methods for functions that are already existing in the parent package?
I would say what extensions do are making more sense to me now. It’s probably not good to export something new from extensions.