TypeFunction example: ImplictConvTargets

Stefan Koch uplink.coder at googlemail.com
Wed Oct 7 15:22:16 UTC 2020


On Wednesday, 7 October 2020 at 14:59:04 UTC, claptrap wrote:
> On Wednesday, 7 October 2020 at 14:40:41 UTC, Stefan Koch wrote:
>> On Wednesday, 7 October 2020 at 14:01:51 UTC, Daniel K wrote:
>>> On Wednesday, 7 October 2020 at 12:56:42 UTC, Adam D. Ruppe 
>>> wrote:
>>>> On Wednesday, 7 October 2020 at 12:37:48 UTC, Stefan Koch 
>>>> wrote:
>>>>> On Wednesday, 7 October 2020 at
>
>> As for the disadvantages. Yes it's a new feature but it blends 
>> so well with the current language that people on here post 
>> correct type function code, (presumably) without having a 
>> compiler that is capable of running it. (It's of course 
>> possible that claptrap cloned my branch and run the code, but 
>> I don't think so ...)
>
> I just based it off what youve posted in this thread.
>
> Maybe my perspective as a relative newbie to D makes me see 
> that as a much bigger payoff than some of the resident 
> greybeards.

You might be happy to see that this exmaple just works with 
talias_master:

---
alias type = alias;

struct KV
{
     string key;
     type value;
}

auto makeAA(KV[] kvs ...)
{
     type[string] result;
     foreach(kv;kvs)
     {
         result[kv.key] = kv.value;
     }
     return result;
}

pragma(msg, makeAA(KV("u32", uint), KV("kv", KV)));
// outputs: ["u32":(uint), "kv":(KV)]
--


More information about the Digitalmars-d mailing list