Module loading `import Module: foo`

Hi,
I have a function e.g. solve in one of my modules and will use that module together with DifferentailEquations. The function in my module does something similar, that’s why the same name. To not override solve, I first do

import DifferentialEquations: solve

and then savely add another method to solve (no clashes, as I am not overriding any functionality of solve from DifferentialEquations), so I can load it together with DifferentialEquations. Now, DifferentialEquations has a long compile and load time, so I do want to avoid having my module depend on DifferentialEquations. What would be ways around that?

I know that there is Recipes to deal with a (similar?) problem when adding plotting functionality but not wanting to depend on specific plotting modules. But I think my use case is a bit different, because I do not call anything from DifferentialEquations.

If you are extending a method, you have to load the particular package — there is no way around that.

To make this faster, well-designed APIs usually group methods and types like this in a lightweight mini-package. This seems to be the case for solve: using

may be enough.

2 Likes

Thanks! That works for me!