Named UDA's

JS js.mdnq at gmail.com
Thu Aug 1 04:01:58 PDT 2013


I guess D doesn't support named UDA's directly?

e.g.,

@(Name = "My Name", Other = .34)

It would be nice to have the ability to have an "attribute" 
hierarchy where looking up attributes on objects could easily be 
done.

e.g.,

@(Name = "s", Other = 2) struct s
{
     @(Name = "q", Default_Value = 4) int q = 4;
}

which would form a hierarchy

Attributes[]...[]

Which @[s].Attributes = {"Name" = "s", "Other" = 2} (Key/Value 
pairs)

@[s][q].Attributes = {"Name" = "q", "Other" = 2, "Default_Value" 
= 4 }

(attributes are inherited

Querying at runtime would be a binary search or O(1) if the 
object type is known.

Anyways, Just an idea I had when trying to make attributes more 
useful.


More information about the Digitalmars-d-learn mailing list