3 ms·
Thank you, this is exactly the sort of comment I was hoping to inspire, and it gave me some food for thought. On first glance, I can see some utility in the AD
by keldaris 10y ago
Thank you, this is exactly the sort of comment I was hoping to inspire, and it gave me some food for thought.
On first glance, I can see some utility in the ADT matching, but not necessarily something I miss in C++ (std::variant + templates gets me most of the way, although there are some issues with that approach). On the other hand, the clean separation of concerns and clear syntax of the traits example looks very useful indeed, and quite tempting.
- Manishearth 10y agoYeah, my point about std::variant is that it doesn't get used pervasively. With a few standardized macros for pattern matching we could get someplace, but right now, like with most new C++ features, codebases and libraries are very selective about the ones they use. This means that your natural C++ "style" can't rely on them, and not all libraries are written with the pattern in mind. OTOH in Rust everything is designed using enums, and any Rust code I write will be free to use enums. It works out quite nicely. In Rust it's not a tool you sometimes might reach for, it's a tool you reach for a lot, because most data is an "or" type.