On Sunday, 25 June 2017 at 17:59:02 UTC, Petar Kirov [ZombineDev] wrote:
So what about something like this:

T sqrt(T)(T n)
where U is Unqual!T: isNumeric!U || is(U == BigInt)
require: n >= 0
ensure result: result * result == n
{
    //Implementation
}

Assuming that in this particular case there's no need for custom error messages, which are still unsupported for template constraints presently.

(I'm aware that this has low chances in getting into the language, I'm just interested in hearing your unbiased opinion as if it was
targeted at a hypothetical D3.)

While I have no issues with changing keywords in the function signature like that [1], removing the parenthesis delimiters makes parsing more complex (and thus slower) for both the human reader, as well as the compiler; for me personally it's the difference between looking at the signature and grasping the meaning instantly and having to verify where the template constraint actually ends.

[1] Strictly speaking require/ensure *are* the words matching the original DbC definition, after all

Reply via email to