compile time class introspection?

Serg Kovrov kovrov at bugmenot.com
Thu Jun 14 15:33:17 PDT 2007


Beginning of the thread is in digitalmars.D.learn

Chris Nicholson-Sauls wrote:
> This is an important thing about D that probably deserves a long and 
> extensive tutorial somewhere...  Many of its cooler features aren't 
> really features at all, but side-effects of other more general features. 
>  So, to reuse this same example, no D doesn't have a way to ask if a 
> class or structure has a particular method.  D /does/ have a way to 
> check for valid types... which, incidentally, non-existant members are 
> invalid types.  So, voila, a side-effect of checking its type is that 
> you confirm it exists.
> 
> There are others... a plethora, even.  Walter is fond of lots of small 
> things that can be put together to achieve amazing things -- and I don't 
> strictly disagree -- but it isn't usually obvious what you can do with 
> those nifty little gadgets.
> 
> -- Chris Nicholson-Sauls

This is really sad that it turned this way. As I understand Walter 
himself criticizes such approach:

"Many useful aspects of C++ templates have been discovered rather than 
designed."

I see idea of designing features as one of major motivations to create D 
programming language in first place. Of course after a "C++ standard is 
unimplementable" <g>

I sincerely hope that in 2.0 specs all workarounds and side-effects will 
be properly (re)designed and will become rather features.

Back to subject, how about define an intuitive syntax for compile time 
checking if method exist in a class/structure?

-- serg.



More information about the Digitalmars-d mailing list