# What is the diffence between abstract type and singleton type

**URL:** <https://discourse.julialang.org/t/what-is-the-diffence-between-abstract-type-and-singleton-type/94258>\
**Category:** General Usage\
**Tags:** question, type\
**Created:** [February 8, 2023, 6:51am UTC](https://discourse.julialang.org/t/what-is-the-diffence-between-abstract-type-and-singleton-type/94258 "2023-02-08T06:51:28Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [February 8, 2023, 12:04pm UTC](https://discourse.julialang.org/t/what-is-the-diffence-between-abstract-type-and-singleton-type/94258/5 "2023-02-08T12:04:15Z")

</div>

> [@zhangwfjh](#):
>
> But why don’t we use abstract type to do dispatch too?

Yes, that works too, and both approaches are viable. (You probably know that dispatching on pure types is quite common, such as with `zeros(Int, 5)`).

But using singleton instances has become a preferred idiom in many cases. See e.g. style guide: [Style Guide · The Julia Language](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-confusion-about-whether-something-is-an-instance-or-a-type)

You may also at some point decide that your singleton type should actually carry some parameter value inside it, to provide more information to the function you are calling, and then it is better if you originally used instance dispatch.

This thread may be of interest: [Singleton types vs. instances as type parameters](https://discourse.julialang.org/t/singleton-types-vs-instances-as-type-parameters/2802)

---

_[View the full topic](https://discourse.julialang.org/t/what-is-the-diffence-between-abstract-type-and-singleton-type/94258)._
