assert(condition[, message]) patch
BCS
BCS at pathlink.com
Wed May 31 16:03:27 PDT 2006
Derek Parnell wrote:
> On Thu, 01 Jun 2006 04:38:50 +1000, Sean Kelly <sean at f4.ca> wrote:
>
>> Some applications ship with asserts left on, and the more information
>> the user has about why the application just halted the better. As
>> others have noted, an optional message also allows state information
>> to be conveyed, which can be useful in the absence of a core dump.
>
> And this is a deployment/development strategy that is flawed. It would
> be better to ship a product without asserts turned on, but if you have
> to show internal issues to a customer then don't use asserts - use
> exceptions or similar to do this at run time. Just use asserts for
> quality assurance prior to shipping.
>
> For me, the golden rule with D is don't use asserts to report errors in
> production releases.
>
An assert is just syntactic sugar for something like:
if(!(cond)) throw new AssertError(__FILE__":"~itoa!(__LINE__)~" Assert
ERROR")
so they are exceptions.
As to not reporting asserts to the user, how about making asserts go to
a special Stream object that can be redirected to a file or something
(if it goes to stderr we're most of the way there). That with a
backtrace log could make for a vary powerful bug hunting tool.
More information about the Digitalmars-d
mailing list