Multiple nested module inclusion

No. It is the more idiomatic solution for maybe-null pointers. If it was a tree, for example, you could also just use a Vector of nodes instead (with the empty Vector playing the role of nothing). The alternative for your case is your type itself having some object that represents the null value. You can create a struct NoWife <: abstract_wife; end and use the only object of this type (i.e., NoWife()) as sentinel for when there is no wife but then I do not see a great advantage over Union{T, Nothing}.

The problem you are having comes from the fact that, in Julia, you should never be requireing the same code at two or more places. You have some alternatives:

  1. Create a package for abstract_stuff, Pkg.develop it, and then just call using PackageName without any require.
  2. Hack LOAD_PATH to include the folder where abstractstuff.jl is inside then, just call using ModuleName without any require.
  3. In your case, in which you are using the REPL, you should probably not be includeing the abstractstuff.jl inside the REPL anyway. You should access it from the module A, like A.abstract_stuff.abstract_wife., without needing to re-include anything.
2 Likes