How to make invariant switchable

Max Samukha outer at space.com
Fri Jun 19 01:14:59 PDT 2009


On Thu, 18 Jun 2009 13:43:22 -0400, bearophile
<bearophileHUGS at lycos.com> wrote:

>Max Samukha:
>> Why would you want to leave asserts in a release build while they are
>> supposed to be used for debugging?
>
>If you look around on internet you will find lot of people that like to keep assertions in the final programs too.
>Is DMD itself compiled with asserts left inside? When DMD doesn't work if often spits out a file + line number that I think come from an assert.
>
>Bye,
>bearophile

You have a point. With current dmd, you can include unittests in the
release build. So why not asserts? But I don't think it's a good
solution to force people who don't want asserts in a final product to
prepend each and every assert with 'debug'. For assertions that should
stay in production, use 'if' conditions in D1 or std.contracts.enforce
in D2. Anyway, it would be nice to have a switch to retain debug
assertions in the release build. 



More information about the Digitalmars-d mailing list