Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-07-18 07:32:31


Russell Hind wrote:
> Ok (and this could go on for ages), but shared_ptr asserts in operator->
> if px is NULL. Surely in that case, you would prefer shared_ptr to
> throw rather than assert. It again is a logic error because the user
> hasn't assigned it a valid value.

But that's BOOST_ASSERT, not assert. BOOST_ASSERT leaves the decision
how to react to the user and I throw an exception instead of aborting
the program. I thought you were suggesting to use the real assert(), not
BOOST_ASSERT. If you just want to use BOOST_ASSERT, than that is
perfectly OK (IMHO)...

> So ultimately, it must come down to preferences. [...]

Not preferences, they depend on the environment which the library
doesn't know about. A library should provide freedom, otherwise it's not
a library but a framework. And boost is not a framework.

> But then some errors should have been caught in testing, [...]

> But this caused more problems that it solved in the end because we now
> ended up with many methods that just used to assert, now throwing at
> run-time and many of these methods were called from destructors. The

Of course testing is needed and the situations where an unexpected
exception is thrown should be very rare. Think of planes: You don't want
the plane to crash, you don't even expect it to crash. But would you
vote for suicide-pills instead of parachutes ;)

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk