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

MysticZach via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 23 07:23:29 PDT 2017


On Friday, 23 June 2017 at 13:00:30 UTC, Steven Schveighoffer 
wrote:
> On 6/23/17 5:06 AM, Solomon E wrote:
>> What I expected from my impression of existing D syntax was 
>> that something like this might be coming up:
>> 
>> T foo(T)(T x, T y)
>>      in (x > 0, y > 0)
>>      out (r; r > 0)
>> {
>>      return x % y + 1;
>> }
>
> The out contract looks pretty good actually. The in contract, 
> not as good. That looks like a comma expression. I'd rather see 
> this be:
>
>      in(x > 0)
>      in(y > 0)
>
> or
>
>      in(x > 0 && y > 0)

I would assume the grammar for these expressions would be the 
same as for `assert`s. So you're right in pointing out the flaw 
above.


More information about the Digitalmars-d mailing list