From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-11 12:09:37
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
Sent: Wednesday, April 11, 2001 11:58 AM
Subject: Re: [boost] any_function (callback) library
> From: "David Abrahams" <abrahams_at_[hidden]>
> > As I have previously posted, throwing an exception in place of an
> > can make misuse much harder to debug. An assertion stops the program at
> > point of the violation without changing its state, often producing a
> > dump or other information which can be used to look at the program state
> > a debugger. An exception causes stack unwinding and other reactions
> > can obscure the cause of the problem.
> Yes, I see the point, but
> * some debuggers can break on throw.
I'm talking about JIT debugging: when you're running outside the debugger,
the program asserts, and the debugger pops up.
Also, there are circumstances (especially during testing of error-handling)
when exceptions happen a fairly significant percentage of the time. You
don't want to stop for every exception, but you need to stop immediately
when there is an assert.
> * you can assert(f); before calling f() if you like; and I would, because
> (1) I have absolutely no guarantee that the documented "undefined
> will assert, (2) this makes it clear for the reader that f is not allowed
> be empty, and (3) my own 'assert' does some additional things, like
> restoring the display mode.
> (1) and (3) can be addressed by documenting that f() calls
> boost::precondition_violation(EMPTY_FUNCTION) when f is empty, where
> boost::precondition_violation can be overriden by the user. But this is
> 'undefined behavior.' It's a well defined behavior that does not throw,
> still checks for misuse.
Yep, that would handle it.
> > It comes down to a question of definitions: is passing a 0 to the
> > constructor misuse, or is it allowed? If it's misuse I want an
> A default constructed function is most certainly not a misuse, although
> not sure whether this is an answer to your question.
It is, but I asked the wrong question by mistake. ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk