Date: 2001-04-11 08:41:45
--- In boost_at_y..., Jesse Jones <jesjones_at_h...> wrote:
> > > 6) Trying to invoke an empty function seems like a precondition
> >> violation to me. Asserting instead of throwing seems preferable.
> >I disagree because using an assertion means that the check might
> >off. If that happens, any_function will cause a segmentation
> >least throwing an exception gives some form of recovery.
> Would you also throw if someone passed a nil char* into
> ctor? Indexed past the end of a std::array? Passed bogus iterators
> into std::find? Personally I don't think any of these should throw:
> they should assert whenever possible and follow the normal code
> thereafter. This is *exactly* what asserts are for.
Indexing past the end of std::array does throw, at least when you use
at() instead of . This kind of throws your whole argument here
out. I'm really learning to hate exceptions. _NO ONE_ agrees on
when they should be used. Even people who think they have their own
set of rules for when to use them seem to violate the rules
themselves from what I've seen.
As for the argument that asserts should be used instead... an assert
is a C concept that existed before exceptions. In fact, other
languages throw exceptions on failed assertions to further cloud this
argument. Saying that this is exactly what assertions are for does
not help to argue your case, or to help people like me figure out
when to use what kind of error handling.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk