Custom attributes (again)

deadalnix deadalnix at gmail.com
Thu Apr 5 14:51:46 PDT 2012


Le 05/04/2012 22:06, Jacob Carlborg a écrit :
> On 2012-04-05 19:35, Walter Bright wrote:
>> On 4/5/2012 5:00 AM, Manu wrote:
>>> C# and Java both have attributes, following these established design
>>> patterns, I
>>> don't think there should be any mystery over how they should be
>>> implemented.
>>
>> At the Lang.NEXT conference over the last 3 days, I was able to talk to
>> many smart people about attributes. But I did find some confusion - are
>> they best attached to the variable/function (i.e. "storage class"), or
>> attached to the type ("type constructor")? I think the former. Attaching
>> it to the type leads to all sorts of semantic issues.
>>
>> From your list of uses, it looks like attaching it to the variable or
>> function is an apropos solution.
>
> If I recall correctly, both Java annotations and C# attributes let you
> specify with a fine grained control on what the attributes are attached to.
>
> @foo FooBar bar () {}
>
> For example, is "@foo" attached to "FooBar" or "bar". Java uses the
> @Target annotation to specify this.
>

This is bar's declaration.


More information about the Digitalmars-d mailing list