Idea for @annotations
soywiz
soywiz at gmail.com
Sat Aug 13 05:53:07 PDT 2011
I really like the idea of annotations to use in traits (compile-time-pseudoreflection).
I have the following code:
http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/hle/kd/rtc/sceRtc.d
Each function has associated a NID. And I have to specify the NID outside, repeating the name of the function and creating a method for that.
Now I have to do:
void initNids() {
mixin(registerd!(0xC41C2853, sceRtcGetTickResolution));
}
u32 sceRtcGetTickResolution() {
//...
}
And with custom attributes/annotations I could do something like this:
struct NID {
uint nid;
}
[NID(0xC41C2853)]
u32 sceRtcGetTickResolution() {
//...
}
And then with traits: allMembers + get custom attributos from each member. The function name only appears once, and the NID appears near the implementation.
More information about the Digitalmars-d
mailing list