assume, assert, enforce, @safe

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 1 15:34:20 PDT 2014


On Friday, 1 August 2014 at 16:52:00 UTC, Daniel Murphy wrote:
> "Sean Kelly"  wrote in message 
> news:tngnltzwxprebpbcdkgm at 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.

Also, I don't like the -debuglib option because when a user sets
the debug flag in their build, what they want is to debug their
own code, not the standard library.  While it's sometimes useful
to have debug symbols in the standard library you're linking
against, it's basically never useful to have internal debug code
enabled in the standard library because even if there's a bug in
that library, you can't do anything about it.  And presumably the
library has been tested against that debug code anyway.


More information about the Digitalmars-d mailing list