TypeFunction example creatiing a conversion matrix
Steven Schveighoffer
schveiguy at gmail.com
Thu Oct 1 18:08:11 UTC 2020
On 10/1/20 1:35 PM, Andrei Alexandrescu wrote:
> On 10/1/20 1:26 PM, Steven Schveighoffer wrote:
>> But when the compiler MUST implement is(T : U), and that expression is
>> well defined, I don't see why we have to reimplement that feature in
>> the runtime as well. At least without a compelling example of "the
>> compiler can't do this as well".
>
> How do you implement Variant.get(T) without reifying is(T : U)?
How do you implement Variant.get(T) *with* reifying is(U : T)?
step 1: determine using reified constructs that U is convertible to T
step 2: ?????
step 3: Return a T from a U!
BTW, Variant already does a *limited* form of this. reification doesn't
change what needs to happen.
I don't see why Variant's needs have to dictate how you need to reason
about types at compile time in CTFE.
-Steve
More information about the Digitalmars-d
mailing list