On 10/31/2010 12:02 PM, Jacob Carlborg wrote:
On 31 okt 2010, at 16:54, David Simcha wrote:
3.  An alwaysAssert() function that stays on in release mode but is otherwise 
equivalent to assert().  I had been using enforce() for this, but I don't like 
that anymore because it throws Exception, not AssertError by default.  This 
means that if I write catch(Exception), I could accidentally be catching what 
is effectively an assertion failure.  Since assert() is supposed to be terse to 
encourage the programmer to use it liberally, explicitly passing AssertError to 
enforce() doesn't cut it.  Mostly what I need here is a better/terser name than 
alwaysAssert().  Given the nature of this feature, I'd say terseness actually 
beats explicitness.  The best I've come up w/ so far is rassert() for release 
assert.
I think it's completely wrong that enforce throws Exception, it should throw an 
exception of its own type, like EnforceException.

Agreed, I've been meaning to suggest that too. I guess it should be a subclass of Exception. It's still tangential to what I'm proposing, though, since IMHO whatever alwaysAssert() throws needs to be derived from Error and should probably be the same thing assert() throws.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to