On Wednesday, 21 June 2017 at 14:22:52 UTC, Moritz Maxeiner wrote:
If you do accidentally forget the extra set of parens on the
`out` contract, you would get "Error: `do` expected before
function body after a bracketed `out` contract" at the end of
the function.
(If, however, it a happens to be a nested function, and the
next statement in that function happens to be `do`, then the
parser will think the `do` loop is the function body... Mmmm,
is this worth worrying about??)
Could you give a specific (short) example of what you think of?
I don't see any potential for ambiguity in the following at a
quick glance, so I'm not sure I got where you think the problem
lies:
---
void foo()
{
int bar(Args...)(Args args)
if (Args.length > 2)
in (args[0] != 0)
in (args[1] > 1)
out (result)(result > 0) { ... }
do {} while (true);
}
---
The only problem is if a programmer forgets to add the additional
parentheses, in which case the bracketed block is then mistaken
for the `out` contract, which will lead to a confusing error
message. For example:
void foo()
{
int bar(Args...)(Args args)
if (Args.length > 2)
in (args[0] != 0)
in (args[1] > 1)
out /*whoops, forgot `( )`*/(result) { ... }
do { ... }
while (true); // Error: while statement cannot contain just `;`
}
Honestly this doesn't seem like a big deal, as I'd imagine it'd
be hard not to notice that code like this wasn't working as
expected. And also extremely rare. So I'm still in favor.