[ ArgumentList ] vs. @( ArgumentList )

Jonas Drewsen nospam4321 at hotmail.com
Thu Nov 8 03:01:12 PST 2012


On Thursday, 8 November 2012 at 00:03:34 UTC, Andrei Alexandrescu 
wrote:
> On 11/7/12 10:24 PM, Walter Bright wrote:
>> On 11/7/2012 11:40 AM, Jonas Drewsen wrote:
>>> I we were to allow for @foobar style UDA then "safe" would 
>>> have to be
>>> a reserved
>>> keyword somehow. Otherwise I do not know what this would mean:
>>>
>>> struct safe { }
>>> @safe void foobar() { }
>>
>> Yes, I agree this is a significant problem.
>>
>
> I think it's solvable. The basic approach would be to plop 
> types "safe", "nothrow" etc. in object.di and then let them 
> just behave like all other arguments.

The original argument that the @ in front of @safe is a way to 
prevent introducing new keywords is all gone then since "safe" 
becomes a normal symbol which is reserved in the library and in 
the compiler to let it do its magic.

Then @safe could just as well be a normal builtin storage class 
called "safe".

* Plopping types "safe","nothrow" etc. into object.di would be a 
breaking change.
* Making @safe, @nothrow into keywords called "safe", "nothrow" 
would be breaking change.

The latter would be the cleanest cut and not have the 
semantic/parse stage problems that Walter mentioned.

Another option would to enforce parenthesis @(safe) for UDA which 
would make it less nice for the eyes to look at.

/Jonas




More information about the Digitalmars-d mailing list