On Thursday, 5 February 2015 at 06:15:39 UTC, H. S. Teoh wrote:
On Thu, Feb 05, 2015 at 05:42:57AM +0000, Meta via
Digitalmars-d wrote:
[...]
I don't know about others (besides Beatophile, who religiously
adheres
to writing contacts), but putting contracts on functions is a
hassle.
I never do it unless I'm feeling particularly full of divine
fervor.
It's a lot like making all variables that don't need to be
changed
immutable (another thing which only Bearophile seems to do) or
properly documenting code. Strong optimization guarantees from
contracts would go a long way in convincing people to actually
write
them (although I guess that's not what you want; Perhaps you
changed
your mind). It's a chicken and egg problem.
I do write contracts in my own code, though not as much as I
would've
because (1) the syntax is far too verbose, (2) dmd makes a mess
of DbC
by putting in-contracts in the callee rather than the caller,
causing
severe limitations in real-life usage, and (3) so far
optimizations
based on contracts (esp. via assert/assume, that Walter was so
insistent
on) haven't materialized yet.
But then again, I do like to document my code a lot too, so
maybe I'm
just One Of Those People. *shrug* (I'm not as extreme as
bearophile in
insisting on putting immutable everywhere, though. Not yet,
anyway. :-P)
T
I've found that the more years of experience I have under my
belt, the less documentation I wrote. When I was starting out I
was very diligent in doing everything the Correct Way so as to
cultivate good habits. I'd find my regression over the years more
alarming if I cared enough.