Annotations or custom attributes

Manu turkeyman at gmail.com
Fri Mar 9 02:56:17 PST 2012


Does D have a nice way to add annotations or custom attributes to entities?

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.

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120309/b9bf3c4d/attachment.html>


More information about the Digitalmars-d mailing list