Pattern matching is-expressions

Paul Backus snarwin at gmail.com
Wed Aug 19 13:15:37 UTC 2020


On Wednesday, 19 August 2020 at 13:07:40 UTC, Stefan Koch wrote:
>
> 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.

Why is it that type functions need their own parallel 
implementation of an existing language feature? Shouldn't it be 
possible to re-use the existing implementation?


More information about the Digitalmars-d mailing list