Struct as subtype of multiple types

First of all, welcome to our community, :confetti_ball:

Second, are you aware that you can have parametrized abstract types? So you do not need to manually create a different type for each number of dimensions?

Second, it seems like a case for the Holy Traits pattern.

Third, why you need these abstract types? You will dispatch on them? Note that you have the following problem: if you have a function f that has a fallback method for the abstract GeometricEntity2D and another for the AbstractPoint but no method for the concrete Point2{T} then which of these two fallback functions should be called? I would suggest considering the following alternative: you can simply create a lot of fallback functions inside modules to simulate “interfaces”, i.e., module GeometricEntity2D has all basic functions that a GeometricEntity2D should implement, i.e., any types that are particular cases of that concept should extend these functions for their concrete type. And then your functions that use GeometricEntity2D types to do more advanced stuff will take generic parameters (not even restricting toGeometricEntity2D) and just call the function the concrete type should have implemented (and if it failed to do so, then an error will be thrown).

6 Likes