Reimplementing the bulk of std.meta iteratively

Stefan Koch uplink.coder at googlemail.com
Thu Oct 1 06:51:08 UTC 2020


On Thursday, 1 October 2020 at 04:08:26 UTC, Walter Bright wrote:
> On 9/28/2020 3:46 PM, Bruce Carneal wrote:
>> Finally, I'd love to hear your comments on type functions vs 
>> reify/dereify.  It's certainly possible that I've missed 
>> something.  Maybe it's a type functions+ solution we should be 
>> seeking (type functions for everything they can do, and some 
>> LDM for anything beyond their capability).
>
> Andrei and I have been mulling over what to do for a while, and 
> have gone through several ideas.
>
> What we're looking for is not a top level solution. We want a 
> fundamental building block, upon which the rest of D's features 
> can exploit naturally and productively. Something that can be 
> explained in 30 seconds.

Type functions take less than 30 seconds.
They take zero seconds.

Do you remember Andrei's non working example?

> alias MostDerived(Args...) = dereify!({
>     auto ids = reify!Args;
>     sort!((a, b) => is(dereify!a : dereify!b))(ids);
>     return ids;
> }());

Here is the correct type function which actually works!

alias[] MostDerived(alias[] types ...)
{
     sort!((alias a, alias b) => is(a : b))(types);
     return types;
}

It is Andrei thought would work.
With type functions it just works.


More information about the Digitalmars-d mailing list