|
Boost : |
From: williamkempf_at_[hidden]
Date: 2001-04-11 12:42:37
--- In boost_at_y..., "David Abrahams" <abrahams_at_m...> wrote:
>
> ----- Original Message -----
> From: "Peter Dimov" <pdimov_at_m...>
> To: <boost_at_y...>
> Sent: Wednesday, April 11, 2001 11:13 AM
> Subject: Re: [boost] any_function (callback) library
>
>
> > From: "David Abrahams" <abrahams_at_m...>
> >
> >
> > > I tend to agree with Jesse here. If somebody wants the throwing
behavior
> > > (s)he can always add it atop the other one.
> >
> > "If somebody wants the throwing behavior from 'new' (s)he can
always add
> it
> > atop the other one." :-)
>
> How? There is no simple wrapper which can do this.
set_new_handler will handle most cases allowing you to change the
behavior. Overloading new for specific types also allows you to do
this. Granted, there are holes in both of these, but so what?
> > > If not, there is no recourse.
> >
> > Why would you want a recourse? The undefined behavior doesn't buy
you
> > anything.
>
> It buys you the ability to take actions which may be more
appropriate than
> throwing an exception.
void foo() throws(foobar)
{
...
}
void bar()
{
try
{
foo();
}
catch(foobar)
{
// do alternate action deemed more appropriate than throwing
}
}
You can always wrap to add exceptions or to remove exceptions. It's
not a one side only thing.
> > If you never call an empty function, you'll never get an
> > exception.
>
> As I have previously posted, throwing an exception in place of an
assertion
> can make misuse much harder to debug. An assertion stops the
program at the
> point of the violation without changing its state, often producing
a core
> dump or other information which can be used to look at the program
state in
> a debugger. An exception causes stack unwinding and other reactions
which
> can obscure the cause of the problem.
That is very much platform specific behavior. Under MS Windows I can
debug exceptions _in exactly the same manner_ in which I debug
assertions. Some simple macros could allow this behavior to be true
on all platforms regardless of built in support for JIT debugging of
exceptions.
> 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
assertion.
Again, explain std::vector::at using this argument.
Bill Kempf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk