DIP 1029---Add throw as Function Attribute---Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Tue Jan 14 20:28:15 UTC 2020
On 1/14/2020 3:21 AM, WebFreak001 wrote:
> I don't think making the attribute "throw" is the best way to go though.
> Currently most attributes use the at-attribute syntax which makes them very
> unambiguous and easier to (visually) parse. I would suggest instead of having
> throw as attribute, the new attribute should be @throws instead. `throws` can
> also be argued for that it is "better" to read like: "function foo throws" than
> "function foo throw"
It's already a keyword so there's no problem with having it be 'throw'.
Having 'throw', 'nothrow' and 'throws' as keywords looks excessive.
> Additionally if we make this an at-attribute, it can very easily be extended in
> the future to have arguments what kind of exceptions are being thrown by this
> function, for example using template argument syntax to be the easiest and most
> consistent to parse. This also exists in other languages like Java and helps
> both with linting for try-catch, but also extremely helps with documentation.
>
> For symmetry with nothrow it might be worth looking into providing nothrow as
> @nothrow attribute instead too.
The @ syntax for this is simply unnecessary.
More information about the Digitalmars-d
mailing list