Custom attributes (again)

Jacob Carlborg doob at me.com
Fri Apr 6 05:41:24 PDT 2012


On 2012-04-06 11:50, Ary Manzana wrote:
> On 4/6/12 3:48 PM, Walter Bright wrote:
>> On 4/6/2012 12:35 AM, Alex Rønne Petersen wrote:
>>> It actually can be a problem. In .NET land, there are many attributes
>>> across
>>> many projects (and even in the framework itself) with the same names.
>>> It turns
>>> out that regular namespace lookup rules alleviate this problem.
>>
>>
>> Perhaps a better scheme is:
>>
>> enum foo = 3;
>>
>> ...
>>
>> @attr(foo) int x;
>>
>> That way, foo will follow all the usual rules.
>
> At least in .Net and Java it's something like this.
>
> 1. You declare your attributes. This is something good, because you have
> a place to say "This attribute is used for marking fields as
> non-serializable".


This is much better, as I've said before.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list