Reimplementing the bulk of std.meta iteratively

Atila Neves atila.neves at gmail.com
Thu Oct 8 09:44:33 UTC 2020


On Thursday, 1 October 2020 at 02:49:43 UTC, Stefan Koch wrote:
> On Wednesday, 30 September 2020 at 23:17:27 UTC, Timon Gehr 
> wrote:
>> On 29.09.20 01:37, Stefan Koch wrote:
>>> [...]
>>
>> It's not a first-class type if you can't declare a variable of 
>> that type. If this does not work, it's not first-class, it's 
>> syntax sugar for reification:
>>
>> type t = int;
>> auto f = (t x)=>x;
>
> Yes I do understand that.
> I was wondering about practical usecases.

import std.algorithm: filter, equal;

type[] types = [int, uint, long, ulong];
auto size4 = types.filter!(a => a.sizeof == 4);
assert(equal(size4, [int, uint]));

No more std.meta.Filter.

> As far as I an aware, if I made the leap to first class types, 
> that would make all usage of them into static polymorphism. 
> (equivalent to templates)
> And with that all the issues come back.

I can't see how that's the case.



More information about the Digitalmars-d mailing list