Why does Julia not support multiple traits?

@tobias.knopp: Maybe we should join our efforts. Look at this: most desired

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

4 Likes

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. 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.

8 Likes

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 (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.

3 Likes

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

1 Like