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

Petar Petar
Tue May 5 14:39:24 UTC 2020


On Tuesday, 5 May 2020 at 08:55:58 UTC, Walter Bright wrote:
> On 4/17/2020 6:03 AM, Tove wrote:
>> I like it, but would prefer:
>> throw!bool
>> 
>> 1) makes meta-programming easier
>> 2) would allow deprecating nothrow (in very long term)
>> 3) there is precedence in C++ 'noexcept(expression)'
>> (even if they made the wrong choice with using the negated 
>> specifier)
>> 
>> Any arguments against?
>
> throw!bool implies it is throwing a bool. Besides, with 
> throw/nothrow we already have the full functionality.

Are you saying that the following will work:

     mixin(doThrow? "throw" : "nothrow")
     void func(bool doThrow)()
     {
     }

?

Otherwise, I'd say that the best solution, which I think Andrei 
agreed with [1] is `attribute(true)` and `attribute(false)` or 
more generally: `attribute(boolExpr)`.

[1]: https://forum.dlang.org/post/mknspb$1dgl$1@digitalmars.com



More information about the Digitalmars-d mailing list