compile time class introspection?

janderson askme at me.com
Thu Jun 14 22:56:09 PDT 2007


Serg Kovrov wrote:
> 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 think its great in C++ that you can do more with it then indented. 
Why limit the programmers imagination?  Sure some hacks should be 
program features, like the static_assert.  However, I think its great 
that you could have static assets in C/++ at all.  In fact many of the 
"improvements" D has are from some great ideas programmers "hacked" into 
C++.

> 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