DIP 1009 (Add Expression-Based Contract Syntax) Accepted

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Apr 11 14:47:14 UTC 2018


On Tue, Apr 10, 2018 at 11:43:00PM -0600, Jonathan M Davis via Digitalmars-d-announce wrote:
[...]
> IMHO, for contracts to be worth much outside of the inheritance case,
> we'd need to do something like make it so that contracts are compiled
> in based on whether the caller used -release or not rather than
> whether the callee did.

This is what should have been done in the first place, and I'd argue
that this is the direction we should be going in. The current
implementation of contracts greatly diminish their value, though
personally I'd still use them because they convey intent better than
just sticking a bunch of asserts at the top of the function body.


> If that were done, then there would be real value in using contracts,
> and I'd be a lot more excited about the new syntax. As it is, it seems
> like a nice improvement that's ultimately pointless.
[...]

I consider this as a first step in improving DbC support in D.  The next
step is to make it so that in-contracts are enforced on the caller's
side rather than the callee's side.  IIRC, the original version of this
DIP included something to this effect, but it was eventually taken off
in order to stay more focused in scope so that the chances of acceptance
would be higher.  But I hope that eventually a future DIP would address
this more fundamental and important issue.


T

-- 
Shin: (n.) A device for finding furniture in the dark.


More information about the Digitalmars-d-announce mailing list