On 09-03-2012 11:56, Manu wrote:
Does D have a nice way to add annotations or custom attributes to entities?
Unfortunately, no.
In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion.
Yes. This is a very needed feature.
For instance, I'm serialising some struct/class using reflection to some text format, but there are a couple of members in a particular class that I don't want to be written. A nice solution might be that I could annotate various members: @DoNotSerialise int thing; ... or something along those lines, whatever concept you want to apply, which I could then inspect in static if() logic to produce some requested additional behaviour. This is a trivial example, but looking at C#/Java, you can see how many useful things can be done with this sort of system. How would it be done currently?
Probably not at all (to my knowledge anyway). -- - Alex