DIP 1009--Improve Contract Usability--Preliminary Review Round 1

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 22 11:31:57 PDT 2017


On Thu, Jun 22, 2017 at 02:08:32PM +0000, jmh530 via Digitalmars-d wrote:
[...]
> My recollection is that the most significant reason to use contracts
> in D is because of contract inheritance. There's a lot of focus in
> this discussion on normal functions, when I would say that contracts
> really aren't even needed.
[...]

I agree that contract inheritance is an important use case, but FWIW, I
write contracts in my non-class methods all the time.  They are useful
to document to the user (i.e., me 3 months later after I forgot the
details of the code) what exactly the function expects / assumes, and
for catching accidental wrong usages.  Coupled with judiciously crafted
unittests, this is invaluable for weeding out bugs in my code both
during coding and also prevents regressions / future wrong usages of the
function later.


T

-- 
People tell me that I'm paranoid, but they're just out to get me.


More information about the Digitalmars-d mailing list