User Defined Attributes (UDA) in Phobos/druntime
Jacob Carlborg
doob at me.com
Tue Jun 11 23:46:05 PDT 2013
On 2013-06-11 23:04, QAston wrote:
> Ok, i see the point now, thanks :). Maybe it'd be worth to enforce that
> convention on a language level, let's say: only types with @attribute
> can be used as UDA. One reason for making that restriction is that when
> there's more than a one way of doing something people will do that using
> all the ways possible. This may be a problem to code which uses many
> libraries simultanously - your utility functions will not interoperate
> with UDAs made by someone else.
Yes, I would like to have the language enforce this. My utility function
fetches by default types that are marked with @attribute. You can add
flag when calling the function to fetch all UDA's.
> BTW I've just found one use case for anonymous UDA:
> @(Enum.Entry) is verbose, the question is: "Is it useful enough to keep
> it, or maybe having single convention is better?"
Is it possible to attach a UDA to an enum member? Or is it possible to
figure out that it's an enum member and check if the enum itself has
@attribute attached to it?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list