Invariants are useless the way they are defined

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Aug 26 11:13:59 PDT 2013


On Mon, Aug 26, 2013 at 11:01:55AM -0700, Andrei Alexandrescu wrote:
> On 8/26/13 9:47 AM, H. S. Teoh wrote:
> >On Mon, Aug 26, 2013 at 06:16:25PM +0200, Timon Gehr wrote:
> >>On 08/26/2013 08:49 AM, deadalnix wrote:
> >>>
> >>>We simply need to add invariant check in the caller, not the
> >>>callee, and not introduce them if the caller is itself subject to
> >>>invariant insertion when called.
> >>
> >>The issue with this is that the invariant is not part of the public
> >>interface.
> >
> >The fact that contracts are not part of the public interface greatly
> >limits the usefulness of DbC in D. If they *were* part of the public
> >interface, there'd be more options to improve it.
> 
> You can attach contracts to an interface. What else would need to be
> done?
[...]

Sorry, I meant the API, not the OO 'interface'.

IIRC, there is a problem with precompiled shared libraries, because the
contracts are compiled into the callee rather than the caller, so there
is no way for user code to specify whether or not the contracts will be
compiled in. If the library was compiled with -release, then no
contracts will be included even if the user code was compiled without
-release; if the library was compiled without -release, then the
contracts will be included even if the user code was compiled with
-release.

This forces the library vendor to have to ship two versions of the
binaries, one compiled with -release, one not.


T

-- 
Кто везде - тот нигде.


More information about the Digitalmars-d mailing list