std.traits vcs __traits

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 16 11:45:33 PST 2017


On Monday, January 16, 2017 11:54:23 Stefan Koch via Digitalmars-d wrote:
> On Sunday, 15 January 2017 at 12:53:04 UTC, Nordlöw wrote:
> > Why is there both
> >
> > http://dlang.org/phobos/std_traits.html
> >
> > and the builtin
> >
> > https://dlang.org/spec/traits.html
> >
> > ?
> >
> > Should we modify std.traits to make use of __traits? I've
> > noticed measurably faster compilations with __traits instead of
> > std.traits for simple things such as isIntegral, isUnsigned,
> > etc.
> >
> > If so, I'll happily make that happen!
>
> There is a simple reason, you don't want complicated
> type-introspection logic welded into the compiler.
>
> The reason why std.traits it slow is because of inefficiencies
> inside the template-system, which I intend to fix.
> Therefore your efforts would be wasted.

I can see that as an argument not to add something that it's in std.traits
to __traits or why something should be added to std.traits rather than
__traits, but if something already exists with __traits, why duplicate that
logic in std.traits? It seems like it complicates std.traits for no benefit
as well as risking having the behavior of  __traits and std.traits differ,
which could cause confusion and bugs.

- Jonathan M Davis




More information about the Digitalmars-d mailing list