I give up! I tried to create a reflection library but D's traits are just too screwed up!

Atila Neves atila.neves at gmail.com
Wed Apr 3 09:24:23 UTC 2019


On Wednesday, 3 April 2019 at 07:22:10 UTC, Alex wrote:

> But D's type system is too screwed up. Fields and members are 
> not treated as types in and have themselves so

I don't know what this means.

> 1. Building a compact code base is impossible.

I beg to differ:

https://github.com/kaleidicassociates/autowrap/blob/master/reflection/source/autowrap/reflection.d

> 2. The type system sometimes requires using alias and sometimes 
> a type yet there is no way to unify the two to reduce code 
> bloat and everything must be duplicated.

void foo(T...)() if(T.length == 1) { /* ... */ }


>3. The Type's do not carry their moodules and
> import automatically so the symbols can be used.

import std.traits: moduleName;
mixin(`import `, moduleName!thingie, `;`);

> This requires getting the module and importanting things. 
> Further more certain _traits want a this object to work for 
> fields

Use T.init when that's the case.

> and others don't but none of the methods seem sensical. 4. If a 
> symbol is private CT __traits fails..., again non-sensical.

See my reply to your other post.





More information about the Digitalmars-d mailing list