Writing pattern matching macros in D.
Deech via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 6 08:27:13 PST 2017
On Monday, 6 March 2017 at 08:27:13 UTC, David Nadlinger wrote:
> On Monday, 6 March 2017 at 02:20:02 UTC, Deech wrote:
>> […] add pattern matching to the language as a macro.
>
> D doesn't have macros per se. However, template metaprogramming
> and mixins can replace them in many cases.
>
> Which particular form of pattern matching do you have in mind?
> You won't get all the way to Haskell (or even Prolog) levels of
> functionality in a generic way, but for limited use cases, it
> is definitely possible.
>
> — David
I was thinking something on the order of Scala's pattern matching
using apply/unapply methods.
http://www.artima.com/pins1ed/extractors.html.
More information about the Digitalmars-d-learn
mailing list