On Wednesday, 30 August 2017 at 14:05:40 UTC, Mark wrote:
I see that in the previous review rounds some people suggested various keywords for designating the return value of a function ("return", "result", ...) in an `out` contract. What about using a plain old underscore? For example:

int abs(int x)
out(_ >= 0)
{
    return x>0 ? x : -x;
}

I think it's good to be consistent with existing out contracts which require declaring the variable first. The identifier `__result` currently works, but the thing is, it takes fewer characters to write `out(r; r >= 0)` than to write `out(;__result >= 0)` (or `out(__result >= 0)`). The possibility of using a single character as the return identifier makes it hard, in my opinion, to justify complaints about the syntax being "too verbose."

Reply via email to