compile time class introspection?

serg why.you.need at my.email
Fri Jun 15 05:36:58 PDT 2007


Jarrett Billingsley Wrote:
> Furthermore, I think type trait detection is particularly weird.  To detect 
> whether a type is a static array, Tango uses the following template:
> 
> template isStaticArrayType( T )
> {
>     const bool isStaticArrayType =
>     is( typeof(T.init)[(T).sizeof / typeof(T.init).sizeof] == T );
> }
> 
> Okay, now we have to instantiate this template time and time again to see if 
> it's a static array, even though *the compiler already knows the answer*. 
> The same goes for all those other type trait templates.  It just seems like 
> a suboptimal solution. 

That's what I'm talking about, D has lot of useful functionality already present. But it either hidden/non-intuitive, or has obvious but not-so-pretty ways to use.

I see people often saying that they love D for is intuitive usage. Yes, comparing to C/C++ its true. I have no other 'compileble' programming languages experience, and interpreted languages is not relevant to subject.

Speaking of introspection - I do *not* want to see runtime complexity added to language. Just compile time introspection That is, ability to like ability to enumerate methods/argguments/types/etc... I want to move as much as possible work from run-time to compile-time. Perhaps compile-time features could affect run-time debug information, but that is a different story...

-- serg.



More information about the Digitalmars-d mailing list