I've just fixed UFCS for the experimental type function branch

Stefan Koch uplink.coder at googlemail.com
Thu Sep 10 19:59:36 UTC 2020

On Thursday, 10 September 2020 at 17:05:02 UTC, Meta wrote:
>     else static if (is(t == A[n], A, size_t n))
>         result += A.sizeOf * n
that is expression introduces 2 symbols `n` and `A`
based on whether t is a static array.
which is something that you cannot do in a type function.
You cannot change the form of the function body.
Type functions are not polymorphic, they cannot change shape.

Besides is there ever a case in which A.sizeOf * n
would not be the same as t.sizeof ?

> Basically, is the implementation at a level where sizeOf can be 
> turtles all the way down, with minimal or no reliance on 
> __traits?

I'd guess you would have higher reliance on __traits simply 
because  __traits have a return value and can be pure, as opposed 
to pattern matching is expressions which can change things 
outside of their contexts.

More information about the Digitalmars-d mailing list