3 ms·
It would be pretty ugly to make this more introspective in C++. For example, if you had to match patterns to distinguish between these three possibilities when
by fooker 1y ago
It would be pretty ugly to make this more introspective in C++.
For example, if you had to match patterns to distinguish between these three possibilities when looking at a tree: (val), (val (tree left) (tree right)), (val (tree subtree)). Here, the possibilities are not really separate types, but rather different ways of constructing a type. This sort of pattern shows up in general purpose programming (even meat and potato imperative programming) pretty often.
There was a proposal for this championed by Stroustrup over ten years ago, but it went nowhere IIRC. https://www.stroustrup.com/pattern-matching-November-2014.pdf https://www.stroustrup.com/pattern-matching-November-2014.pd...