On 05/07/2018 05:35 PM, Paul Backus wrote:

Personally, I consider [pattern matching] an essential feature--arguably *the* essential feature--

After having used Nemerle, I tend to agree.

I haven't gotten around to using this yet, but I did take a look at the source and was blown away by how small and simple it is. Kudos!

Oh, and I love that it's much easier to remember how to spell than "Algebraic" :)

That said, it would be really nice if D made it possible for a tool like this to support more things being defined in-line. For example, in Nemerle, it's possible to define a binary tree like this:

---------------------------------
// Mainly from:
// https://github.com/rsdn/nemerle/wiki/Grok-Variants-and-matching
variant Tree {
  | Node {
      left  : Tree;
      elem  : int;
      right : Tree;
    }
  | EmptyLeaf
}
---------------------------------

But AFAIK, in D, each part would have to be defined separately, making the overall structure less clear:

---------------------------------
struct Node {
    Tree* left;
    int   elem;
    Tree* right;
}
struct EmptyLeaf {}
alias Tree = SumType!(Node, EmptyLeaf);
---------------------------------

Of course, that's not your lib's fault, just an unfortunate limitation of D.

Reply via email to