DIP 1009--Improve Contract Usability--Preliminary Review Round 1

MysticZach via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 09:52:24 PDT 2017


On Wednesday, 21 June 2017 at 14:49:09 UTC, Moritz Maxeiner wrote:
> On Wednesday, 21 June 2017 at 13:24:24 UTC, MysticZach wrote:
>>
>> So weird how this discussion is happening in parallel with 
>> this other discussion :-) :
>>
>> http://forum.dlang.org/post/rkdpuuggltowhqmcmmke@forum.dlang.org
>
> It is, though as I have pointer out over there, I would really 
> like to decouple assert semantics from the new contract 
> semantics to achieve the maximum elegance we can within the 
> design limits of the language.

Well I'd be just as happy expanding the design limits of the 
language, i.e. `assert`, if that were a better option. The issue 
you raise is just how different are `in` and `out` contracts from 
regular `assert` contracts. They _are_ all listed in the same 
section of the documentation [1], for whatever that's worth.

The practical question is whether one can assume that the same 
semantics used for `assert`, whatever they may be, will in all 
cases be desirable for `in` and `out` too. The flexibility of 
decoupling them is one solution, if they are clearly sufficiently 
different. But another option is simply to upgrade `assert` to 
make sure it offers what everyone wants. I don't know what to 
suggest, because I don't if `assert` can be made good enough to 
warrant direct inclusion into the grammar. If it could, then all 
contracts, including plain `assert` statements, would benefit 
from them.

[1] https://dlang.org/spec/contracts.html


More information about the Digitalmars-d mailing list