DIP 1029---Add throw as Function Attribute---Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Fri Feb 7 08:56:06 UTC 2020
On 1/14/2020 1:22 PM, Dennis wrote:
> On Tuesday, 14 January 2020 at 10:44:17 UTC, Mike Parker wrote:
>> #DIP1029
>> #throw
>
> First of all thanks for adding the section with a grammar diff and adding it to
> FunctionAttribute. I forgot to mention during draft review it should probably be
> added to StorageClass as well:
> https://dlang.org/spec/grammar.html#StorageClass
>
> Otherwise it can't appear in an AutoFunctionDeclaration unlike nothrow.
> ```
> void main() {
> nothrow foo() {} // currently allowed
> throw foo() {} // not allowed after this DIP because `throw` is no
> `StorageClass`
> }
> ```
>
> However, adding it to StorageClass adds an ambiguity:
>
> ```
> void foo()() {
> nothrow bar(); // allowed according to grammar spec
> throw bar(); // throw statement or function declaration?
> }
> ```
I'm pretty sure the parser can take care of that with lookahead.
More information about the Digitalmars-d
mailing list