Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-04 15:36:02


"E. Gladyshev" <egladysh_at_[hidden]> writes:

> --- David Abrahams <dave_at_[hidden]> wrote:
> [...]
>> If your system gives you cause to worry about catch(...), it's much
>> simpler to use the destructors of automatic objects than to define
>> such a complicated mechanism for recovery.
>
> Of course you should worry about catch(...) on any real system.

There are plenty of real systems where unexpected errors are never
translated into C++ exceptions.

> Here is my last point.
>
> My concern is that boost is a very respectable
> site and community, so most people will look at your article
> that has the following code:
>
> template <class X>
> void print_random_sequence()
> {
> std::vector<X> v(10); // A vector of 10 items
> try {
> // Provides only the basic guarantee
> v.insert( v.begin(), X() );
> }
> catch(...) {} // ignore any exceptions above
> // print the vector's contents
> std::cout "(" << v.size() << ") ";
> std::copy( v.begin(), v.end(),
> std::ostream_iterator<X>( std::cout, " " ) );
> }
>
>
> and assume that it is safe to use this approach in their programs
> and that they are covered from trouble.

I don't expect people to take small snippets of code from a large
article out-of-context and without thinking. If they do, it's their
problem; they're going to run into lots of problems in their
programming practices regardless of exceptions.

> It is really really dangerous.

Please. If you wrote that code expecting it to print a random
sequence of numbers, do you really think it would be in a system
where it would cause real danger?

Wait, don't answer that. I'm done here.

> I suggest for you to at least elaborate in your article on some
> of the issues that have been discussed in this thread.

The article is copyrighted by Springer Verlag, and can't be changed.
It was originally published in M. Jazayeri, R. Loos, D. Musser (eds.):
Generic Programming, Proc. of a Dagstuhl Seminar, Lecture Notes on
Computer Science. Volume. 1766. See
http://www.springeronline.com/sgw/cda/frontpage/0,10735,5-0-22-2032348-0,00.html

But I wouldn't want to change it anyway.

Sorry,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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