Feature request: Optional, simplified syntax for simple contracts

TommiT tommitissari at hotmail.com
Tue Jun 18 01:08:01 PDT 2013


On Tuesday, 18 June 2013 at 02:38:28 UTC, Manu wrote:
> On 16 June 2013 12:22, TommiT <tommitissari at hotmail.com> wrote:
>
>> On Sunday, 16 June 2013 at 00:19:37 UTC, Manu wrote:
>>
>>> Super awesome idea! How about coma separated expressions to 
>>> perform
>>> multiple asserts?
>>>
>>> int func(int i, int j) in(i<5, j<10)
>>> {
>>>   return i + j;
>>> }
>>>
>>
>> Do you mean ...to get more specific error messages than with 
>> in(i<5 &&
>> j<10) ?
>>
>
> Error messages would be more useful, and it may be much easier 
> for the
> compiler/optimiser to use this information in the future as 
> separated out
> into distinct expressions.

I don't really know about this stuff, but since assert and 
enforce are built-in things, why couldn't they be smart enough to 
tell me which ones of the sub-expressions returned false.

a = 4;
b = false;
c = 11;
d = true;
assert(a < 5 && (b || c < 10) && d);

AssertError: { true && (false || false) && ? }

It doesn't know the last expression because it didn't evaluate it.


More information about the Digitalmars-d mailing list