Design of related modules wrt pkg

tldr:

  1. regarding use of pkg, are these two examples both doing the same thing (one parent pkg exports functions from all the others)?
  2. is there case where one might instead do: each child pkg uses functions from a common parent (DifferentialEquations.jl has this relationship with DiffEqBase, but in general does not use this model)

Sorry this is a bit open ended, just looking for a bit of clarification on two examples of ‘hierarchical package design’ that seem to have different implementations of using, and when to use which:

ex 1: DifferentialEquations.jl


module DifferentialEquations

  using Reexport

  @reexport using DiffEqBase
...
  import DiffEqBase: solve
...
end

ex 2: FinEtools.jl

module FinEtools
...
using .FTypesModule: FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict
# Exported: basic numerical types, type of data dictionary
export FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict
...
end

background:
I have one body of code with fairly specific functionality and several more bodies of code that use this functionality, but otherwise have very different dependencies (one even has c code wrapped), I want to package these as separate modules for maintainability.

Just put the shared code in a third module/package and have both of the other packages use it with using.

2 Likes