Hi Guys
Is there a way to pass a function from a submodule (saved in a separate file) as a default argument to a sibling function?
As an example, say that my module is structured as follows:
module Parent
import A: a
import B: b
import C: c
import Child: foo
export bar, a, b, c, other_objects
# Do some stuff here
end
----------------------------
# Child.jl
module Child
export foo
function foo(MyFunc::Function=Parent.a, x::Int=1, y::Float64=1.234)
# Do some other stuff here
end
end
Ultimately, I want to be able to
- call submodule functions, e.g.
Parent.a()
/Parent.b()
/ … - call
Parent.foo()
with default arguments, - pass sibling module functions as arguments, e.g.
Parent.foo(MyFunc=Parent.b)
I want to avoid importing A: a, B: b, ...
within Child.jl
if posssible.
When I try to use this format, Child
fails to precompile when I load Parent
…
Any help would be greatly appreciated!
Thanks