UDAs - Restrict to User Defined Types?

simendsjo simendsjo at gmail.com
Thu Nov 8 10:55:13 PST 2012


On Thursday, 8 November 2012 at 17:20:39 UTC, Jacob Carlborg 
wrote:
> On 2012-11-08 17:53, simendsjo wrote:
>
>> 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 {}
>>
>
> I don't know really. In that bottom example, the struct 
> declartion almost disappears among all the attributes.

Yeah.. But at least you'll always know where to look.

@[serializable, xmlRoot, attribute, displayName("foo")]
struct foo {}

@[serializable, xmlRoot, displayName("foo")]
struct @foo {}

but attribute could be required as the last type, and on a line 
of it's own, giving:

@[serializable, xmlRoot, displayName("foo")]
@attribute
struct foo {}



More information about the Digitalmars-d mailing list