User Defined Attributes

Walter Bright newshound2 at digitalmars.com
Tue Nov 6 08:04:52 PST 2012


On 11/6/2012 7:55 AM, Jacob Carlborg wrote:
> 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;
>

There's a lot more you can do with the ArgumentList syntax than associative 
arrays. Furthermore, there remains the problem of how mtype fits into the name 
scoping system.


More information about the Digitalmars-d-announce mailing list