On Friday, 23 June 2017 at 16:21:28 UTC, H. S. Teoh wrote:
On Fri, Jun 23, 2017 at 09:06:59AM +0000, Solomon E via
Digitalmars-d wrote: [...]
T foo(T)(T x, T y)
in (x > 0, y > 0)
out (r; r > 0)
{
return x % y + 1;
}
Hmm, I like this syntax for out-contracts! It borrows from
existing foreach syntax, so it has some precedence, whereas the
previous proposal of `out(...)(...)` looks uglier and also
looks deceptively like a template function declaration.
`out (r; r > 0)` gets my vote.
OTOH, I don't like the comma in the in-contract. Let's just
keep it as either separate clauses:
in (x > 0)
in (y > 0)
Yeah, my take is that the grammar for `assert`s applies to the
new syntax as well. If the grammar for asserts is this:
AssertExpression:
assert ( AssertParameters )
... then the grammar for the new syntax is:
InExpression:
in ( AssertParameters )
OutExpression:
out ( ; AssertParameters )
out ( Identifier ; AssertParameters )