On 3/17/2011 3:08 PM, Andrei Alexandrescu wrote:
if (!condition) { writeln("my message %s %s", __FILE__, __LINE__);
assert(0); }
I am strongly opposed to using enforce() for bug detection.
There's nothing wrong with encapsulating this idiom (if frequent). That's what
essentially alwaysAssert does. So you're right but without contradicting
dsimcha's suggestion.
Sure, but there is plenty wrong with using enforce() for bug detection even if
alwaysAssert does not exist. For one thing, such uses encourage others to
misunderstand and misuse enforce.
Additionally, alwaysAssert is an obvious one liner. I think such things need to
be very frequently used to consider them part of the standard library.
Otherwise, we risk Phobos becoming a morass of trivia.