www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Feature for paranoids

reply Fyodor Ustinov <ufm ufm.su> writes:
Hi!

Is it possible when using the "-release" indicate that this one 
in/out/invariant/assert should not to be disabled?

WBR,
     Fyodor.
Nov 10 2015
next sibling parent Kagamin <spam here.lot> writes:
I wouldn't recommend release mode to paranoids. I personally use 
`debug invariant` and `debug assert` for purely debugging code.
Nov 10 2015
prev sibling next sibling parent reply ponce <contact gamesfrommars.fr> writes:
On Tuesday, 10 November 2015 at 13:09:09 UTC, Fyodor Ustinov 
wrote:
 Hi!

 Is it possible when using the "-release" indicate that this one 
 in/out/invariant/assert should not to be disabled?

 WBR,
     Fyodor.
Since assert(false) is special (cf. http://p0nce.github.io/d-idioms/#assert%28false%29-is-special) you can use the following construct to have always-on assertions: if (!cond) assert(false); instead of: assert(cond); But -release will still remove your in/out/invariant blocks.
Nov 10 2015
parent reply Fyodor Ustinov <ufm ufm.su> writes:
On Tuesday, 10 November 2015 at 15:44:26 UTC, ponce wrote:

 Since assert(false) is special (cf. 
 http://p0nce.github.io/d-idioms/#assert%28false%29-is-special) 
 you can use the following construct to have always-on
assert(false) AKA assert(0) - is a part of this language that I think it is absolute evil. WBR, Fyodor.
Nov 10 2015
parent ponce <contact gam3sfrommars.fr> writes:
On Tuesday, 10 November 2015 at 20:37:00 UTC, Fyodor Ustinov 
wrote:
 assert(false) AKA assert(0) - is a part of this language that I 
 think it is absolute evil.

 WBR,
     Fyodor.
I would say it's a minor evil, that create problems by needing an explanation. At this point it has been discussed to death already.
Nov 10 2015
prev sibling parent reply cym13 <cpicard openmailbox.org> writes:
On Tuesday, 10 November 2015 at 13:09:09 UTC, Fyodor Ustinov 
wrote:
 Hi!

 Is it possible when using the "-release" indicate that this one 
 in/out/invariant/assert should not to be disabled?

 WBR,
     Fyodor.
I don't quite get why you'd like to use -release if you are paranoid enough to be afraid of assert(0)'s little difference in behaviour. Could you give a realistic use case? At the very least seeing why it is important to you can only be beneficial to the community.
Nov 10 2015
parent Fyodor Ustinov <ufm ufm.su> writes:
On Tuesday, 10 November 2015 at 20:46:14 UTC, cym13 wrote:

 I don't quite get why you'd like to use -release if you are 
 paranoid enough to be afraid of assert(0)'s little difference 
 in behaviour. Could you give a realistic use case? At the very 
 least seeing why it is important to you can only be beneficial 
 to the community.
It will be too much text on the too poor English. :) WBR, Fyodor.
Nov 10 2015