www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - throw new RangeError() prevents algorithm.iteration from being nogc

reply Ivan Butygin <ivan.butygin gmail.com> writes:
Is there any reason to use construct like `version (assert) if 
(empty) throw new RangeError();` intead of `onRangeError()` or 
just plain assert?
Worse, this causes  nogc to differ between release and debug.

See also: https://run.dlang.io/is/7h48fC

Thanks
Jan 30
parent Alex <sascha.orlov gmail.com> writes:
On Wednesday, 30 January 2019 at 19:44:58 UTC, Ivan Butygin wrote:
 Is there any reason to use construct like `version (assert) if 
 (empty) throw new RangeError();` intead of `onRangeError()` or 
 just plain assert?
 Worse, this causes  nogc to differ between release and debug.

 See also: https://run.dlang.io/is/7h48fC

 Thanks
I would say, no. As if you want to assert, then, nogc would ignore that, and if you release, the assert holds automatically. If you want to throw, it would pass nogc during debug, but resist during release compilation. However, maybe I'm missing some relevant context...
Jan 30