I’m trying to create a Julia modules for simple mathematical functions, but I want to separate code which calculates from code which show stuff on the screen (plot recipes).
I want each mathematical domain to be in their own module (QuadraticFunctions, CubicFunctions) because I want to learn about precompilation. This way, if I change one module, I don’t have to precompile all my work environment.
The problem is that in order to create a recipe, like plot(some_data, color=:green)
(code may be wrong, but focusing on having a specific color to a specific Module), I need to either mention my block uses Plots/Makie or imports Plots/Makie.
This means that I suddenly added this huge dependency on my calculation package just because I want to make a few plotting recipes available.
Plots/Makie will be imported and used on a main.jl
like
using QuadraticFunctions
using CubicFunctions
using Plots
gr()
##### plots and calls to functions exported by both modules #####
Is there any better solution I’m not thinking about? Or do I just have to separate one module into two modules so I have QuadraticFunctions
and QuadraticFunctionsRecipes
, which depends on the calculations module? This way, changes to the internals of the modules which calculate will only trigger recompilation of their own things, not including any graphical package.