DIP 1006--More selective control over contracts--Formal Review

Neia Neutuladh via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 15 17:15:37 UTC 2017

On Friday, 15 September 2017 at 14:25:56 UTC, Mike Parker wrote:
> The first stage of the formal review for DIP 1006 [1], 
> "Providing more selective control over contracts", is now 
> underway. From now until 11:59 PM ET on September 29(3:59 AM 
> GMT on September 30), the community has the opportunity to 
> provide last-minute feedback. If you missed the preliminary 
> review round [2], this is your chance to provide input.
> At the end of the feedback period, I will submit the DIP to 
> Walter and Andrei for their final decision. Thanks in advance 
> to those of you who participate.
> [1] https://github.com/dlang/DIPs/blob/master/DIPs/DIP1006.md
> [2] 
> http://forum.dlang.org/post/rsafosvkhxddkxptaziy@forum.dlang.org

"invariants stand out in that regard: they can be used on a 
pay-for-what-you-use basis, by using assert(object) (or 
assert(this)), but they are also implicitly called twice on every 
public and protected class method call. The call itself is not 
direct: the compiler inserts a call to _d_invariant, which can be 
found in druntime."

On DMD 2.076.0, it's once per public method (inserted into the 
method body just before returning). Awkwardly, this is still done 
for final classes with no invariants defined locally or in base 

Changing it to a virtual function call, eliminating it for final 
classes when possible, etc would greatly reduce the cost. But may 
as well go whole hog.

More information about the Digitalmars-d mailing list