March 21, 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.
April 20, 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;
>
>> The limitations we have here are owed by the constrained support of type level programming. We can't do all what we can do at runtime at compile time because the static programming is very limited except? we execute a runtime function at compile time but a runtime function can also be executed at runtime and can't handle transformations on types because types don't exist at runtime, but strings exists at runtime, right?
>> ...
>> If we would have AliasMap which is mutable, then maybe.
>
> 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.

Why don't you give an example of what *outcome* you are trying to achieve first, maybe in a language you are more familiar with, and then we can tell you how to do it in D.

1 2
Next ›   Last »