Custom attributes (again)

Ary Manzana ary at esperanto.org.ar
Fri Apr 6 03:37:49 PDT 2012


On 4/6/12 6:29 PM, Timon Gehr wrote:
> On 04/06/2012 12:12 PM, Walter Bright wrote:
>> On 4/6/2012 2:50 AM, Ary Manzana wrote:
>>> The syntax in Java for declaring an attribute:
>>>
>>> public @interface Foo {
>>> String xxx;
>>> int yyy;
>>> }
>>>
>>> In D maybe @interface could be used to (in order to avoid introducing
>>> another
>>> keyword... or maybe use @attribute instead):
>>>
>>> @attribute Foo {
>>> string xxx;
>>> int yyy;
>>> }
>>
>> I don't see the need for creating a new kind of symbol.
>>
>
> It would behave like a struct anyway. The issue is whether any struct
> should be allowed to be used as an attribute, or whether a runtime
> instance of an attribute can be created.
>
> Syntax could just as well be this:
>
> @attribute struct Foo {
> // ...
> }

True, I struct can be fine. And I don't see any problem in using it in 
runtime. Though I'm sure nobody would like it to remain in the obj file 
if it's only used at compile time...


More information about the Digitalmars-d mailing list