User Defined Attributes

deadalnix deadalnix at gmail.com
Wed Nov 7 12:38:26 PST 2012


Le 07/11/2012 21:35, Walter Bright a écrit :
> On 11/7/2012 4:01 AM, Jacob Carlborg wrote:
>> I start to more and more think it would be better to explicitly
>> require the
>> developer to declare an attribute, like:
>>
>> attribute foo
>> {
>> string name;
>> }
>>
>> @foo("asd") int a;
>
> Adding a whole new aggregate type is a pretty intrusive and major change.
>

So let's defined in object.d the following :

@attribute struct attribute {}

And then mark as @attribute anything that may used as attribute.

@attribute struct foo {
	string name;
}

@foo("asd") int a;

If wasn't marked as @attribute, it wouldn't be an valid attribute.


More information about the Digitalmars-d-announce mailing list