# Question regarding Abstract types

**URL:** <https://discourse.julialang.org/t/question-regarding-abstract-types/54557>\
**Category:** New to Julia\
**Tags:** type\
**Created:** [February 3, 2021, 7:51pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557 "2021-02-03T19:51:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![owinter92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/owinter92/32/21346_2.png) [@owinter92](https://discourse.julialang.org/u/owinter92)\
**Post date:** [February 3, 2021, 7:51pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557/1 "2021-02-03T19:51:34Z")

</div>

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

```julia
abstract type AbstractGeometricObject end

const Vec <: AbstractGeometricObject = SVector

```

---

<div class="post-metadata">

**Author:** ![doit](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@doit](https://discourse.julialang.org/u/doit)\
**Post date:** [February 3, 2021, 7:58pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557/2 "2021-02-03T19:58:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![owinter92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/owinter92/32/21346_2.png) [@owinter92](https://discourse.julialang.org/u/owinter92)\
**Post date:** [February 3, 2021, 8:02pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557/3 "2021-02-03T20:02:00Z")

</div>

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

```julia
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”?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [February 3, 2021, 9:29pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557/4 "2021-02-03T21:29:19Z")

</div>

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

> **[GitHub - mauro3/SimpleTraits.jl: Simple Traits for Julia](https://github.com/mauro3/SimpleTraits.jl)**
>
> Simple Traits for Julia. Contribute to mauro3/SimpleTraits.jl development by creating an account on GitHub.

or

> **[GitHub - tk3369/BinaryTraits.jl: Can do or not? It's easy. See...](https://github.com/tk3369/BinaryTraits.jl)**
>
> Can do or not? It's easy. See https://tk3369.github.io/BinaryTraits.jl/dev/ - GitHub - tk3369/BinaryTraits.jl: Can do or not? It's easy. See https://tk3369.github.io/BinaryTraits.jl/dev/

---

<div class="post-metadata">

**Author:** ![owinter92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/owinter92/32/21346_2.png) [@owinter92](https://discourse.julialang.org/u/owinter92)\
**Post date:** [February 3, 2021, 9:36pm UTC](https://discourse.julialang.org/t/question-regarding-abstract-types/54557/5 "2021-02-03T21:36:49Z")

</div>

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