User Defined Attributes (UDA) in Phobos/druntime
QAston
qaston at gmail.com
Wed Jun 12 08:22:53 PDT 2013
On Wednesday, 12 June 2013 at 06:46:06 UTC, Jacob Carlborg wrote:
> 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?
Accrding to this http://dpaste.dzfl.pl/728872fa it's not possible
to attach an UDA to enum member. I think that what you propose,
together with parametrisation made by IdanArye to your @attribute
definition is a nice compromise for now. It allows reuse of utils
and interoperation, sets up a convention to follow and does not
enforce language changes. But it will only work if it's going to
be in phobos for example as std.attribute. In my opinion such
compromise would be easier to get into the language than fully
enforcing the convention and I think it's very important to have
some form of UDAs for serialization just for users' convenience.
More information about the Digitalmars-d
mailing list