On Saturday, 22 July 2017 at 03:05:55 UTC, aberba wrote:
How about this in current syntax? (that's what I do)

int func(int a)
    in
    {
        assert(a >= 0);
    }
    out(result)
    {
        assert(result >= 2);
    }
body
{
    return 2 * a;
}


an improvement could be:

int func(int a)
    in assert(a >= 0);
    out(result) assert(result >= 2);
body
{
    return 2 * a;
}

just like an in-line if-else statement

That was actually part of my original proposal [1]. People in that discussion [2] seemed more excited about the current proposal , and they won me over to it. If the syntax doesn't assume `assert`, probably 99% of contracts will use it explicitly, so it's really making it easier by just assuming it. And being allowed to omit the word `body` (now `do`) with the new syntax is an important feature. That said, I don't think your proposal is incompatible with the current one. It just might be made unnecessary by it.

[1] https://github.com/dlang/DIPs/blob/d2dc77802c74378cf4545069eced21f85fbf893f/DIPs/DIP1009.md

[2] http://forum.dlang.org/post/[email protected]

Reply via email to