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:
- Create a package for
abstract_stuff,Pkg.developit, and then just callusing PackageNamewithout anyrequire. - Hack
LOAD_PATHto include the folder whereabstractstuff.jlis inside then, just callusing ModuleNamewithout any require. - In your case, in which you are using the REPL, you should probably not be
includeing theabstractstuff.jlinside the REPL anyway. You should access it from the moduleA, likeA.abstract_stuff.abstract_wife., without needing to re-include anything.