Can we make mixin applications first class at the type level?
sighoya
sighoya at gmail.com
Thu Mar 21 13:15:59 UTC 2019
On Thursday, 21 March 2019 at 12:56:59 UTC, FeepingCreature wrote:
> On Thursday, 21 March 2019 at 12:49:44 UTC, sighoya wrote:
>> No, they don't. std.meta give you AliasSeq:
>>
>> template AliasSeq(TList...)
>> {
>> alias AliasSeq = TList;
>> }
>>
>> which seems to be a hack.
>> Does it work if I want to have a map instead, no!
>>
>
> staticMap... do you mean a mapping of types to other types? Use
> specialized templates:
>
> alias foo(T : int) = string;
> alias foo(T : string) = float;
>
Okay, thanks for mentioning this. I think this is the mosaic I
was missing.
> It sounds like you're committed to doing imperative logic to
> manipulate types, when there's a rich library of functional
> template-based solutions to type problems. Could D offer ctfe
> native manipulation of types? Sure, and it would be handier in
> many situations, but there's a rich library of functional,
> template-based idioms available for your use that can, in my
> opinion, probably solve any type problem you have, and won't
> require you using strings as a weird metalanguage out of no
> clearly established need.
Yes, I would like to manipulate on types like I would manipulate
on values in D. Playing with alias this to achieve these things
feels like a bit of encoding D into another language.
But okay, using alias this for maps is a with immutable updates+
recursion seems to be a big step forward until real first class
types arrive.
More information about the Digitalmars-d
mailing list