assume, assert, enforce, @safe

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 16:49:04 PDT 2014


On Wed, Jul 30, 2014 at 08:05:35PM -0300, Ary Borenszweig via Digitalmars-d wrote:
> On 7/30/14, 7:01 PM, Walter Bright wrote:
> >I'd like to sum up my position and intent on all this.
> >
> >7. using enforce() to check for program bugs is utterly wrong. enforce()
> >is a library creation, the core language does not recognize it.
> 
> What do you suggest to use to check program bugs?

This is what assert is designed for.

But if you don't want to check ever to be removed, currently you have to
write:

	if (!requiredCondition)
		assert(0); // compiler never removes this

which IMO is relatively clear, and the use of assert(0) for forceful
termination is consistent with existing practice in D code.


T

-- 
Старый друг лучше новых двух.


More information about the Digitalmars-d mailing list