August 01, 2013 Named UDA's | ||||
---|---|---|---|---|
| ||||
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. |
August 01, 2013 Re: Named UDA's | ||||
---|---|---|---|---|
| ||||
Posted in reply to JS | On Thursday, 1 August 2013 at 11:02:00 UTC, JS wrote:
> Anyways, Just an idea I had when trying to make attributes more useful.
struct Name
{
string data;
}
@Name("hello")
void foo();
I favor this approach much more because of strong typing.
|
Copyright © 1999-2021 by the D Language Foundation