So, User-Defined Attributes

Jacob Carlborg doob at me.com
Fri Jan 4 15:38:23 PST 2013


On 2013-01-04 21:33, Era Scarecrow wrote:

> This is sorta like tuples; But from the brief summaries I cannot fully
> understand how or where they would be used. I understand some attributes
> can be made and added that some compilers may use (@noreturn as an
> example), but outside of the compiler I'd need an example of how to make
> use of them.
>
> Since there's no runtime component, then aside from carrying a tuple and
> some information forward at compile-time, what else can it do? How would
> you use it? Are there any special tuple formats that give information to
> automatically be included/compiled into the structs/classes without
> having to resort to mixins?

It could be used for serialization, for example. Have a look at my 
serialization library, Orange.

http://dl.dropbox.com/u/18386187/orange_docs/orange.serialization.Serializable.html

Look at the "NonSerialized" template, that could now be replaced by a 
UDA. Like this:

class Foo
{
     int a;
     @NonSerialized int b; // will not be (de)serialized
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list