On Fri, Aug 01, 2014 at 10:34:20PM +0000, Sean Kelly via Digitalmars-d wrote: > On Friday, 1 August 2014 at 16:52:00 UTC, Daniel Murphy wrote: > >"Sean Kelly" wrote in message > >news:tngnltzwxprebpbcd...@forum.dlang.org... > > > >>Druntime uses contracts and asserts in places. Which are of course > >>removed because we ship only a "release" build. Once again, the worst > >>naming for a compiler switch ever. What I really want is a way to ship > >>release and non-release builds (ie. checked and unchecked) and have the > >>proper one chosen at link time based on build flags. Basically toss the > >>-defaultlib and -debuglib and replace it with -checkedlib and > >>-uncheckedlib. > > > >While shipping a debug version of druntime would be useful, I think the > >real problem is that checking preconditions is disabled by the callee! If > >preconditions are violated, the error is in the caller, and checking > >should be enabled based on the application's flags. > > Exactly. When the user builds with -release set, DMD should link > the unchecked libphobos. And without this flag it should link > the checked build. So the user choice of whether to use > contracts extends at least to the standard library. [...]
I don't like this. This would mean that every D library, whether it's Phobos or some 3rd party library, must now ship with checked & unchecked versions, if they want DbC to work. IMO the correct solution is for the compiler to insert preconditions at the calling site, rather than the callee. The separate compilation problem can be solved by having dmd include preconditions in .di files so that binary-only distributions will still work. T -- There are two ways to write error-free programs; only the third one works.