Pattern matching is-expressions

Stefan Koch uplink.coder at googlemail.com
Wed Aug 19 13:07:40 UTC 2020


On Wednesday, 19 August 2020 at 12:56:37 UTC, Adam D. Ruppe wrote:

> So there could be a little tweak/fix to the scope lifetime of 
> these symbols but it does overall work really quite well and 
> there's ways to avoid at least some of the symbols if you like 
> and maybe the others should be able to be set to local or 
> whatever too.
>
> But it does do a LOT of useful things.

Yes it is useful.
And I think I have found a way to support them within the 
typefunctions.
is(T S == super) would become
auto f(alias T)
{
    static literal bool r = is(T S == super);
    // here alias S = (r ? SuperTupleOf(T) : ErrorType) is 
automatically declared.
    // where ErrorType is the value for which `!is(ErrorType)` is 
true
}

still the pattern matching part is going to be a pain to 
implement correctly.
Without the some limitations we have right now.


More information about the Digitalmars-d mailing list