Proposal: user defined attributes

Jacob Carlborg doob at me.com
Sun Mar 25 08:24:16 PDT 2012


On 2012-03-22 02:23, Tove wrote:

> mixin(attr(q{struct Foo
> {
> @NonSerialized int x;
> @NonSerialized int y;
> int z;
> }}));
>
> void main()
> {
> auto m = [ __traits(allMembers, Foo) ];
> writeln("Normal members of Foo:", m);
>
> auto n = [ __traits(allMembers, Foo_Serializable) ];
> writeln("Serializable members of Foo:", n);
> }
>

Just really ugly and it creates a new type, completely unnecessary if D 
supported user defined attributes.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list