[ ArgumentList ] vs. @( ArgumentList )

Nathan M. Swan nathanmswan at gmail.com
Wed Nov 7 00:32:16 PST 2012


On 11/06/2012 10:18 AM, Walter Bright wrote:
> For User Defined Attributes.
>
> In the north corner we have the current champeeeeon:
>
> -------
> [ ArgumentList ]
>
> Pros:
>      precedent with C#
>      looks nice
>
> Cons:
>      not so greppable
>      parsing ambiguity with [array literal].func();
>
> ------
> In the south corner, there's the chaaaaallenger:
>
> @( ArgumentList )
>
> Pros:
>      looks like existing @attribute syntax
>      no parsing problems
>
> Cons:
>      not as nice looking
> ------
>
> No hitting below the belt! Let the games begin!

[], because @ should be reserved for future language keywords.

Whenever people post suggested language features that require some 
marking, they introduce a new @attribute, because introducing a plain 
keyword breaks code. If you have @UDAs, this further limits language 
expansion.

Example: let's say you want to introduce a "nogc" mark:
     1. Not a nogc keyword, that could break "bool nogc;"
     2. If you have @, @nogc could break an "enum nogc;" attribute.
     3. Now you're stuck with __nogc or #nogc or something uglier.

There is a familiar-to-other-langauges advantage to @, but there is a 
better-than-other-languages advantage to [].

My thoughts,
NMS


More information about the Digitalmars-d mailing list