So I have a lot of thoughts on this topic. =) I’ve not been able to find time to write down my latest, but I think the path I would like to see is roughly that we build on RFC 1546, which permits traits to have fields. Roughly speaking, traits would play the role of “abstract classes” or “interfaces” in OO terminology, and specialization would be used to handle inheritance.
Anyway, some other “related work”:
- http://smallcultfollowing.com/babysteps/blog/2015/05/05/where-rusts-enum-shines/
- http://smallcultfollowing.com/babysteps/blog/2015/05/29/classes-strike-back/
- http://smallcultfollowing.com/babysteps/blog/2015/08/20/virtual-structs-part-3-bringing-enums-and-structs-together/
- http://aturon.github.io/blog/2015/09/18/reuse/
- http://smallcultfollowing.com/babysteps/blog/2015/10/08/virtual-structs-part-4-extended-enums-and-thin-traits/
Of those, the one on @aturon’s blog is probably most relevant to my current thoughts about traits and fields, since it describes how specialization works. But I think that the other articles are still interesting, and I’d like to see motion towards variants having their own types – eventually. (Or, more narrowly, towards making it more convenient to work with closed sets of classes, which is not the OO default.)