Make using compiled libs with debug code better

bauss jj_1337 at
Wed Oct 20 06:09:32 UTC 2021

On Tuesday, 19 October 2021 at 13:57:31 UTC, Steven Schveighoffer 
> On 10/18/21 5:51 PM, Elronnd wrote:
>> On Monday, 18 October 2021 at 13:04:47 UTC, Steven 
>> Schveighoffer wrote:
>>> Would it be a reasonable thing to change contracts to be 
>>> called by the caller instead of the callee? Is that something 
>>> that could make its way into D, such that the input checking 
>>> of functions that are compiled for release still can run when 
>>> you compile your code in non-release mode?
>> What if I take a pointer to a function with contracts and call 
>> it from someplace that doesn't know about those contracts?
> A good point. There are also issues with virtual functions 
> along these lines.
> The only thing I can think of is to compile the contract code, 
> provide 2 entry points for the function, and let the caller 
> pick the one they want. This would have the same effect.
>> Better to leave assertions on by default, and make you have to 
>> go out of your way to turn them off.  IMO.
> This would leave Phobos in pretty bad shape for performance. 
> Especially with invariants. I know for instance that 
> RedBlackTree has an invariant that validates the tree 
> correctness on every operation (and this runs before and after 
> every function). However, if you build your project with dub, 
> every library you depend on (with source available) will be 
> built the same as your application. So Phobos is kind of alone 
> in this regard based on the way we distribute libraries.
> I'm not sure what the right answer is, but that is what this 
> thread is for -- can we solve this in a non-disruptive or 
> minimally-disruptive way?
> -Steve

The solution to that problem would be assertion levels, like you 
declare how important an assertion is and then you can toggle 
based on that.

More information about the Digitalmars-d mailing list