DIP 1009--Improve Contract Usability--Preliminary Review Round 2 Begins

MysticZach via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 21 09:52:38 PDT 2017


On Friday, 21 July 2017 at 15:13:09 UTC, Timon Gehr wrote:
> "in and out expressions must come at the end of the function 
> declarator suffix, and before the regular contracts, if any"
>
> The implementation actually allows all possible notations for 
> contracts to be mixed freely. Whether or not 'do' is required 
> depends on what notation is used by the last contract.

I decided that for grammar purposes it would be easier to require 
the contract expressions before the contract blocks. Contract 
blocks are currently conflated grammatically with FunctionBody 
[1]. An accurate grammar that describes the current 
implementation would be twice as complicated, because 
FunctionBody would have to be redefined. I want the feature to be 
as simple as possible to understand, so I didn't think it was 
worth it.

There has also been mention of the possibility of improving the 
implementation of contracts to allow separate compilation, in 
which case the signature, plus contracts, could some day appear 
without the body. I wanted to define the new expressions to 
accommodate this possibility.

[1] https://dlang.org/spec/grammar.html#FunctionBody


More information about the Digitalmars-d mailing list