Against enforce()

bearophile bearophileHUGS at lycos.com
Thu Mar 17 08:49:25 PDT 2011


Steven Schveighoffer:

> All the other points, I disagree with bearophile, enforce is not assert
> and should not be nothrow.

I have never said this. I am aware that enforce can't be nothrow, and I agree that in some situations you want to raise an exception instead of using asserts. One of the things I have said (maybe wrongly) are:

>You have to add that such "if (!condition) throw new Exception(args)" idiom is common in Phobos because Phobos is present only in release mode. If the zip distribution of DMD contains two Phobos and dmd becomes able to use the right one according to the compilation switches, then I think that "if (!condition) throw new Exception(args)" will become more rare, and the enforce() too will be less commonly needed.<

Bye,
bearophile


More information about the Digitalmars-d mailing list