# Why does Julia not support multiple traits?

**URL:** <https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278>\
**Category:** Internals & Design\
**Tags:** traits\
**Created:** [August 8, 2017, 11:36am UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278 "2017-08-08T11:36:07Z")\
**Posts on this page:** 5\
**Page:** 3

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [August 14, 2017, 9:02am UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/41 "2017-08-14T09:02:28Z")

</div>

@tobias.knopp: Maybe we should join our efforts. Look at this: [most desired](https://discourse.julialang.org/t/list-of-most-desired-features-for-julia-v1-x/4481/124)

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [August 14, 2017, 9:46am UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/42 "2017-08-14T09:46:32Z")

</div>

Yes, I am currently travelling but can contribute to a document in a week.

Let’s make this a real julep, I.e. a design document that outlines the features. Juleps is just markdown living in a julialang repo.

Note that I have the same vision as you have outlined

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [August 14, 2017, 10:17am UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/43 "2017-08-14T10:17:59Z")

</div>

> [@tobias.knopp](#):
>
> The usual answer one gets here when asking for multiple inheritance is: we don’t need that we have holy traits.

No, I don’t think Holy-traits are seen as the “solution”, merely a stop-gap pattern until a time when traits are implemented at a language level.

Yes, I too think that _traits_ and _multiple inheritance for abstract types in which types can be added after creation_ are essentially identical. Of course, the latter is a bit of a mouth-full and would need a name: “trait” is a good one. In particular, if we semantically separate them from “interfaces”/“protocols” as you seem to suggest in point 3 and as I suggested [above](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/12). Also, once you add interfaces and have a correspondence of them to abstract types, I think point 2 is needed. Or it would be a bit strange to have a type which implements the interface but is not a subtype of the corresponding abstract type.

And, yes, I also agree that in the end there should be one “dispatch system” and not some on types, some on traits, some on …

Last, I still think that traits of several types would be good to have: some interfaces in a multi-dispatch world will involve several types and it would be nice to encode them as a trait. To translate this into MI-speak, it would mean to add a supertype to a type tuple, say `Tuple{Int,Float64}<:SomeAbstractType`.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [August 14, 2017, 2:41pm UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/44 "2017-08-14T14:41:49Z")

</div>

I don’t really think a design is required for this – it’s pretty well understood. Multiple inheritance where you can add ancestors to types after-the-fact is what I described in [issue #5](https://github.com/JuliaLang/julia/issues/5) (the oldest open issue). This is the maximally powerful design. It is also the hardest design to implement, and makes #265 look like child’s play compared to the kinds of updates you might need to do in order to keep the world coherent. Sometimes it’s a good idea to give people a lot of power in a language feature, but other times it’s better to restrict the power you give them. It’s still unclear which situation this is.

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [August 14, 2017, 3:28pm UTC](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278/45 "2017-08-14T15:28:13Z")

</div>

Ok, I you have a plan than I will be patient.

[Previous page](https://discourse.julialang.org/t/why-does-julia-not-support-multiple-traits/5278.md?page=2)
