On Wednesday, September 29, 2010 05:39:25 Sclytrack wrote: > > nobody gets pissed off and defensive when he compares D unfavorably to > > Python. > > > > > No matter what I say, I'm always wrong. Even quotes from encyclopedias > > > or research papers are more wrong when I share them. > > Compile-time custom annotation might be hard to implement. Do we really > need it? Going from compile-time to runtime might not be obvious too. > > > class MarkThis : CustomAnnotation > { > > } > > class A > { > @MarkThis("test",10) > void test() > { > //MarkThis obj = (MarkThis) getCustomAnnotation( ... ); //at > runtime //even invoke methods of the annotation. > } > } > > Method test <--linked to--> annotation MarkThis and parameters ("test", > 10)
Custom annotations can be very powerful and highly useful. Now, lacking runtime reflection, exactly how useful they'd be would differ from languages such as Java or C#, but they could still be of great value. Ideally, they are a feature which would be in D at some point - and since adding them would likely be purely additive rather than having to make breaking changes, they could be added at pretty much any point in D's development. However, I do think that D would do a lot better to have dmd and Phobos progress quite a bit more before even considering adding such a feature. - Jonathan M Davis