User Defined Attributes

Jacob Carlborg doob at me.com
Tue Nov 6 07:55:09 PST 2012


On 2012-11-06 16:39, Walter Bright wrote:
> On 11/6/2012 5:04 AM, Jacob Carlborg wrote:
>> I agree, I a syntax like this would have been nicer:
>>
>> @mtype("key" : "value") int a; or @mtype(key : "value") int a;
>> @mtype("value") int b;
>> @mtype int c;
>>
>
> Part of what I was trying to do was minimizing inventing new syntaxes. The
>
>     [ ArgumentList ]
>
> invents nothing new but the brackets. Your proposal is both a new
> syntax, and it can only do key/value pairs - nothing else.

It depends on how you look at it.

* @mtype - is the same syntax as the current syntax for attributes
* @mtype("key" : "value") - Uses the above in combination with the 
syntax for associative array literals

How about this then:

@mtype("foo", 3, "bar") int a;

And have the argument list be optional? I really like to have a short 
nice looking syntax for the simple use cases, i.e.

@mtype int b;

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list