Proposal: user defined attributes
    Andrei Alexandrescu 
    SeeWebsiteForEmail at erdani.org
       
    Fri Mar 16 09:09:54 PDT 2012
    
    
  
On 3/16/12 8:35 AM, Adam D. Ruppe wrote:
> enum Serializable { yes, no }
>
> @note(Serializable.yes) int a;
[...]
> foreach(i, exp; __traits(getNotes, a)) {
> static assert(is(typeof(exp) == Serializable);
> static assert(exp == Serializable.yes);
> }
So we have:
class A {
     @note(Serializable.yes) int a;
     ...
}
vs. a hypothetical in-language solution:
class A {
     int a;
     mixin(note("a", Serializable.yes));
     ...
}
I wonder to what extent the in-language solution can be made to work.
Andrei
    
    
More information about the Digitalmars-d
mailing list