For context, the full example I am working on are the two extensions
- Manopt.jl/ext/ManoptJuMPExt.jl at kellertuer/JuMP-vectorize · JuliaManifolds/Manopt.jl · GitHub
- Manopt.jl/ext/ManoptJuMPManifoldsExt.jl at kellertuer/JuMP-vectorize · JuliaManifolds/Manopt.jl · GitHub
But I’ll try to narrow that down to an MWE.
If we assume we write an extension to package A
when B
is loaded. It requires some internal struct like
module ABExt
struct MyStuff{T}
field::T
end
end
where the MyStuff
is mainly an internal boilerplate-wrapper (maybe even <: SomeAbstractTypeFromB
) to wrap something from A
to be used within B
. It provides some basic extension stuff that is nice to have.
Now assume that we can extend this even further as soon as C
is loaded. We can surely just do a second extension to A
to be
module ABCExt
# [ ... ] where I would like to use `MyStuff` as well
end
C
basically has new nice types for T
that enables further extension of the functionality to these types. So for best of cases, I would like to use MyStuff{T}
for that as well, it would spare me some default functions I already defined in ABExt
.
Suce I could do a MyStuff2{T}
struct and copy those over to this types as well. But I know that the other one is loaded, since ABExt
will be loaded (at some point) when ABCExt
.
So is there any way to make MyStuff
being known within ABCExt
?
That would be awesome, no only because it would reduce (not much but a bit) of code duplication – but it would also semantically be super nice!
edit: In practice MyStuff
is a subtype of some B.Type
and has a field with a type from A
. For that reason it can not be a struct in the main package A
.