On Tuesday, 28 June 2016 at 06:13:44 UTC, Superstar64 wrote:
Right now, D functions expect a Block Statement (https://dlang.org/spec/function.html#FunctionBody) as their function body. Changing that to allow any statement (https://dlang.org/spec/statement.html#Statement) would provide a few new syntactic sugars like:
---
auto func(MyObj obj) with(obj)
{
    //...
}

auto func(int arg) return arg;

auto func() try
{
    //...
}
finally
{
    return //...
}
---

Incidentally, yesterday I stumbled upon a very long C++ function whose body was a try/catch statement instead of a block statement. It took me some time to figure out what was going on, and, although I'm usually ok with these kind of language "features", I have to say that this can really harm readability, because flow control is no longer indented with respect to the declaration.

Reply via email to