Feature request: Optional, simplified syntax for simple contracts
TommiT
tommitissari at hotmail.com
Sat Jun 15 14:45:15 PDT 2013
"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;
}
More information about the Digitalmars-d
mailing list