StaticArrays: Sub-typing from FieldVector

New to Julia for serious programming, only having dabbled with the REPL for the last 7 years. I’m interested in using StaticArrays to experiment with. My plan is to create an abstract subtype of FieldVector:

module MyMod

import StaticArrays as SA

abstract type MVector{N,T<:AbstractFloat} <: SA.FieldVector{N,T} end


and then define concrete sub-types of this. The reason why I want to sub-type from FieldVector is because there are cases where I want to provide documentation specific to my problem domain, without committing type piracy.

My question is, how can I, for example, create a Vector3 concrete subtype of my custom MVector abstract type, such that the {N,T<:AbstractFloat} parameters are encoded into the type definition and passed to the abstract type correctly. I want to specifically avoid type annotations in constructor call sites. I have tried several incantations on writing such a struct definition, and all I get is a not-very-useful:

ERROR: LoadError: invalid subtyping in definition of Vector3

Any help would be appreciated showing me how to write this subtype correctly. Thanks!

You want a concrete, parametric type, probably, like:

struct Vec3{T} <: FieldVector{3,T}
1 Like

Thank you very much!