Question regarding Abstract types

Hi, can I include nickname of concrete type as suptype of my Abstract type? Something like this:

abstract type AbstractGeometricObject end

const Vec <: AbstractGeometricObject = SVector

No, that is not possible.
You can either wrap the type in your own type or possibly use a trait. But that depends on what exactly you try to do.

The idea is to define dummy function for abstract type and then define later for concrete

abstract type AbstractGeometricObject end

dim(v::AbstractGeometricObject) = "Not defined."
dim(v::Vec) = returns dimension of the vector

I don’t really want to wrap it up in struct as I see it as not necessary. What do you mean by “use a trait”?

Is there a need for the dummy function? All it does is throw the equivalent of a method error. If you just don’t define it, Julia throws the method error for you.

As for traits, it looks like you don’t need them here, but in case you do, see


Well not really, but it does not solve the problem. I guess I just wrap it in struct.