Re: Recursively defined matcher function

2021-01-03 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 3 January 2021 at 18:26:44 UTC, Per Nordlöw wrote: alias Matcher = Match function(Matcher[] matchers...); but it errors as recursive alias declaration Preferrably I wanted a non-templated definition.

Re: Recursively defined matcher function

2021-01-03 Thread sighoya via Digitalmars-d-learn
On Sunday, 3 January 2021 at 18:55:58 UTC, sighoya wrote: ``` alias matcherSignature(T:matcherSignature!T) = Matcher (T[] matchers...); ``` Yet, it is right: ``` alias matcherSignature(T:matcherSignature!T) = Matcher function(T[] matchers...); ``` But it didn't work likewise, you have t

Re: Recursively defined matcher function

2021-01-03 Thread sighoya via Digitalmars-d-learn
On Sunday, 3 January 2021 at 18:49:40 UTC, sighoya wrote: ``` alias matcherSignature(T:matcherSignature!T) = T (T[] matchers...); ``` Ahhh, I meant this: ``` alias matcherSignature(T:matcherSignature!T) = Matcher (T[] matchers...); `` I think we would require proper singleton types to m

Re: Recursively defined matcher function

2021-01-03 Thread sighoya via Digitalmars-d-learn
On Sunday, 3 January 2021 at 18:26:44 UTC, Per Nordlöw wrote: I've tried alias Matcher = Match function(Matcher[] matchers...); but it errors as recursive alias declaration The closest thing can I think of is: ``` alias matcherSignature(T:matcherSignature!T) = T (T[] matchers...);

Recursively defined matcher function

2021-01-03 Thread Per Nordlöw via Digitalmars-d-learn
How can I define a function type `Matcher` that takes an array of `Matcher`s and returns an instance of a `struct Match` defined as struct Match { @safe pure nothrow @nogc: static Match zero() { return typeof(return)(0); } static Match none() { return typeof(r