Question on Idiomatic Julia, Traits, and Types

It’s not clear what the goal is here, perhaps you should give a more complete example, but one thing that I’m pretty sure of is that there’s no point to storing a field for dimension count inside a type that’s only ever intended to support 1D (or 2D, in the case of the other type). That’s redundant.

You could, for example, have a method dimensions:

dimensions(::Type{MyStruct_1D}) = 1
dimensions(::Type{MyStruct_2D}) = 2

That would make you dim field unnecessary.

Probably it would be even better if you could design a single type that would be parameterized by number of dimensions:

struct MyStruct_ND{dim} <: MyAbstractType ... end