Pattern matching via switch?
simpletangent at gmail.com
Mon Mar 16 23:00:30 UTC 2020
I've been playing around with this via inheritance lately (I'm
aware of the sumtype package but specifically wanted to use
objects instead of structs), had some good results.
It involves a bit of boilerplate though. I'm essentially using
the visitor pattern + an anonymous class implementing a matcher
I would love to use templated return values from the match()
method, though. Does anybody know how to do that without the
compiler complaining ("'final' functions cannot be 'abstract'") ?
Specifically, is there any way to make:
abstract void match(Matcher m);
abstract T match(T)(Matcher!T m);
More information about the Digitalmars-d-learn