Boost logo

Boost :

Subject: Re: [boost] [inspect] exceptions (FW: [Boost-users] no exceptions)
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-03-24 23:01:33


On Thu, Mar 24, 2011 at 6:04 PM, Dave Abrahams <dave_at_[hidden]> wrote:
> At Thu, 24 Mar 2011 17:49:55 -0700,
> Emil Dotchevski wrote:
>>
>> On Thu, Mar 24, 2011 at 4:50 PM, Dave Abrahams <dave_at_[hidden]> wrote:
>> > At Thu, 24 Mar 2011 11:27:23 -0700,
>> > Emil Dotchevski wrote:
>> >>
>> >> > That said, "libraries should generally use BOOST_THROW_EXCEPTION" is a
>> >> > good rule for Boost, and I wouldn't mind having something like it in
>> >> > the inspect tests, provided that libraries with a legitimate reason
>> >> > not to use it can be registered as exceptions to the rule.
>> >>
>> >> Maybe I'm missing something but what is an example of such a legitimate reason?
>> >
>> > For example, "it buys nothing, because the library can't really work
>> > as coded without exception support."  Such is the case for
>> > Boost.Python, I believe.
>>
>> Whether it makes the library useful in BOOST_NO_EXCEPTIONS builds is
>> best left for the user of the library to decide.
>
> No, really.  Python throws exceptions as a matter of course (e.g. loop
> termination).  These get translated into C++ exceptions.

Maybe I don't use for loops in my python scripts then. Regardless how
dumb this is, as a matter of principle the library shouldn't care
exactly how the user program satisfies the requirements of
BOOST_THROW_EXCEPTION.

>> At any rate, you gain nothing from not using BOOST_THROW_EXCEPTION.
>
> One fewer dependencies?  Not that I really care; I'd be happy to use
> it.  It's just that it's also very easy for me to imagine that some
> libraries might be exceptions to the rule.

You have a point, but consider that boost/throw_exception.hpp includes
boost/config.hpp, adding only about 500 lines of C++.

>> Besides, even if the library remains useless in BOOST_NO_EXCEPTIONS
>> builds, I wouldn't say that BOOST_THROW_EXCEPTION buys nothing.
>
> What does it buy in this case?

- Enables transporting of exceptions between threads

- Enables transporting of arbitrary data in exception objects

- Enables boost::diagnostic_information to return a better message
(double-clicking the message in Visual Studio and other editors' log
window opens the throw location.)

It seems unreasonable to consciously take these away from the user.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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