On Sunday, 14 May 2017 at 01:30:19 UTC, Timon Gehr wrote:
On 14.05.2017 00:07, Petar Kirov [ZombineDev] wrote:

How would you feel about:

if(condition){ then(); }
{ otherwise(); }

I don't see any problem, ...

The intention is that in this _hypothetical_ (hence "would") grammar (which is somewhat analogous to what is proposed in 3), the second block would bind to the if-statement as the 'else' case, but I see how that is confusing.

And my case still stands - if you were to format the code like this:

Again, this is not about formatting. Reformat the code as you wish. With your reformatting, it would actually be even less obvious.

I now see what you meant, but the two ideas are not equivalent.
Making 'else' optional is not possible, because it can change
the meaning of existing code, while making 'body' optional would not.

Edit: I may be wrong. Here's a case that's on the edge of ambiguity:

void main()
{
    void inner(int x)
    in { }
    {
        writeln("WAT");
    }
}

If 'body' was optional, what would be the output of the program? It turns out that the output would be empty, because function bodies are required for functions with 'in' or 'out' contracts, making the block bind to the 'inner' function,
instead of 'main'.

Reply via email to