On Sunday, 3 February 2013 at 22:00:05 UTC, bearophile wrote:
Nick Sabalausky:
Why is it silly? (Genuine question)
"Silly" wasn't the right word, sorry.
But generally if a language offers you a clean feature (D
contract programming is designed clean enough) it's better to
use it, when you clearly need it.
I don't use D contracts, even though I use asserts.
I find that adding contracts bloats my code quite a lot, making
it less readable.
real log(real x)
in
{
assert(x > 0);
}
body
{
return ...;
}
v.s.
real log(real x)
{
assert(x > 0);
return ...;
}
As far as I'm aware there is no difference except when
inheritance is involved, so it's an easy choice for me.