UDAs - Restrict to User Defined Types?

simendsjo simendsjo at gmail.com
Thu Nov 8 08:53:18 PST 2012


On Thursday, 8 November 2012 at 13:19:29 UTC, Jacob Carlborg 
wrote:
> On 2012-11-08 11:56, simendsjo wrote:
>
>> Or
>> struct @foo {}
>> interface @foo {}
>> enum @foo {0
>> etc
>
> That syntax looks a bit backwards to me. What if I want to 
> annotate the attribute.
>
> @serializable struct @foo {}
>
> Looks a bit confusing which is the name of the attribute and 
> the which is the attached annotation.
>
> Vs
>
> @serializable @attribute struct foo {}
>
> No confusion here, "foo" is the name of the attribute, the rest 
> is attached annotations.

I guess it depends. I find it easier to see that it's an 
attribute, especially when you annotate it. But it's harder to 
grep for.

Is foo an attribute or not?
   @serializable
   @xmlRoot
   @attribute
   @displayName("foo")
   struct foo {}

Is foo an attribute or not?
   @serializable
   @xmlRoot
   @displayName("foo")
   struct @foo {}



More information about the Digitalmars-d mailing list