How does __traits and std.traits differ?
    Jacob Carlborg via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Jul 24 00:39:42 PDT 2015
    
    
  
On 2015-07-24 09:16, WhatMeWorry wrote:
>
> Looking at the online documentation, it says:
>
> __traits "are extensions to the language to enable programs, at compile
> time, to get at information internal to the compiler."
>
> std.traits are "Templates which extract information about types and
> symbols at compile time.
>
> Do they both basically do the same thing?  They both have isIntegral,
> but there is a lot of functionality that they don't share.
>
> I guess one naive question would be, why not just have all the __traits
> functionality rolled into std.traits?  Or vice versa?
A couple of reasons:
* std.traits existed before __traits
* In some cases std.traits might provide a more user friendly interface 
than __traits. I think that __traits is not intended to be used directly 
by users. Rather it should server as a building block for a library 
implementation. That's why it has double underscore prefix.
* It's not possible to implement everything that __traits does in a 
library solution, i.e. std.traits
-- 
/Jacob Carlborg
    
    
More information about the Digitalmars-d-learn
mailing list