D is dead

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Sep 1 14:31:36 UTC 2018


On Sat, Sep 01, 2018 at 01:26:01PM +0000, rjframe via Digitalmars-d wrote:
> On Thu, 23 Aug 2018 07:27:56 +0000, JN wrote:
[...]
> > (has anyone ever used contracts?).
> 
> I do.

Me too.  They are very useful to express intent, even if the current
implementation leaves some things to be desired.


> It's a shame D doesn't take them seriously.

Not sure what you mean by that.  Care to elaborate?


> As it is, I generally use them solely to express intent, which you
> don't get by placing asserts in the function body. I often read the
> function signature of functions I'm calling without reading the body,
> so separating the asserts from the body is helpful.
[...]

Yes.  The current implementation of contracts leaves some things to be
desired, but I'm hopeful after the recent syntax revamp was accepted and
merged into git master.

The next milestone to fight for is pushing the checking of contracts to
the caller, rather than the callee.  This will be important to solve the
currently very annoying (and debilitating) problem with binary shared
libraries, in that it will allow the same shared binaries to be used
when compiling both with and without contracts.  It should be the end
user's build script that decides whether or not contracts are compiled
in, but currently this is not the case.

This change may also address the current hackish implementation of
subclass contracts (which involves catching Errors, an arguably
dangerous thing to do), though I'm not 100% sure.


T

-- 
Старый друг лучше новых двух.


More information about the Digitalmars-d mailing list