On Tuesday, 18 June 2013 at 05:27:57 UTC, deadalnix wrote:
On Saturday, 15 June 2013 at 21:45:16 UTC, TommiT wrote:
"Simple things should be simple, complex things should be possible." -Alan Kay

I'd like to simplify the syntax of function pre- and post-conditions when the contract block consists of a single assert statement. A special syntax for this special case would omit all of the following:
1) the block's curly braces
2) the assert keyword
3) the semi-colon ending the assert statement
4) the body keyword (if and only if it follows right after the block)

So, instead of writing this:

int func(int i)
in
{
   assert(i < 5);
}
out(r)
{
   assert(r < 9);
}
body
{
   return i * 2;
}

...you'd be able to write this:

int func(int i)
in (i < 5)
out(r) (r < 9)
{
   return i * 2;
}

I'd rather reserve this kind of syntax for static contract checking or something similar.

Isn't signature constraint (the if clause) good enough for all static contract checking purposes?

Reply via email to