TypeInfo in the library

Jacob Carlborg doob at me.com
Sat Feb 15 03:04:45 PST 2014


On 2014-02-14 01:42, Adam D. Ruppe wrote:

> I think the others are already possible:
>
> string TypeInfoImpl!T.toString() { return T.stringof; }
> interface TypeInfo {} /* TypeInfoImpl(T) : TypeInfo */

Currently what .stringof evaluates to and the format of it is not 
specified and should not be relied. I assume the current 
typeid(T).toString is reliable.

> // ElementType used for illustration only, no need to depend on phobos
> since we can do this with an is expression too. that's just harder to
> read/write lol
>
> TypeInfo TypeInfoImpl!T.next() { return typeid(ElementType!T); }
>
> Interfaces and parent class can also be done with traits today, so we
> can auto-generate the with a template too.

What about the rest of the fields, in ClassInfo, for example? Implement 
with traits? I'm thinking of "classInvariant", "m_flags", "deallocator", 
"defaultConstructor" and so on.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list