Discussion Thread: DIP 1029--Add throw as Function Attribute--Final Review

Petar Petar
Tue May 5 16:47:11 UTC 2020


On Tuesday, 5 May 2020 at 15:55:30 UTC, Paul Backus wrote:
> On Tuesday, 5 May 2020 at 15:30:38 UTC, Tove wrote:
>> Good digging! I agree with you and Andrei, but using template 
>> syntax would be an additional improvement, it's not about 
>> saving one char, but avoiding matching () in the common case.
>>
>> attribute!true
>> attribute!false
>> attribute!(boolExpr)
>
> It seems more confusing to me to use template syntax for 
> something that isn't a template.
>
> We already use parentheses for stuff like `extern(C)`. Using 
> them for function attributes is a natural extension of that.

If we turn the existing function attributes into compiler 
recognized UDAs, the template version is one char shorter:

     version (A)
     {
         struct nogc { bool enabled; }
         void foo() @(nogc(true)) { }
     }
     else version (B)
     {
         struct nogc(bool enabled) { }
         void foo() @(nogc!true) { }
     }


;)


More information about the Digitalmars-d mailing list