[bind10-dev] whether/when to use exceptions (Re: 2009-10-08 BIND 10 meeting)
Christos Zoulas
christos at zoulas.com
Fri Oct 9 00:45:42 UTC 2009
On Oct 8, 3:44pm, jinmei at isc.org (JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKE) wrote:
-- Subject: whether/when to use exceptions (Re: [bind10-dev] 2009-10-08 BIND
| At Thu, 8 Oct 2009 16:19:22 -0400,
| christos at zoulas.com (Christos Zoulas) wrote:
|
| > | If we take exceptions off the table, I say we write the whole thing in
| > | Python or Ruby. Removing major features of the reason we chose C++
| > | would mean we chose poorly.
| >
| > Well, the biggest problem I have with exceptions is that they lead to
| > resource leaks. Since there are no checked exceptions you cannot know
| > if I function that you call is going to throw, so for every OS resource
| > you use (fd, shared memory segment, malloced space without smart pointers)
| > you must make sure that there is no exception that is going to cause you
| > to leak it.
|
| Resource leaks are certainly a common compliant against (C++)
| exceptions, and I guess "without smart pointers" is a key here. Maybe
| I'm naive, but in my understanding many of resource leak problems with
| exceptions can be smartly avoided using RAII techniques (including the
| use of smart pointers). If we decide to rely on exceptions relatively
| heavily, I guess we should equally heavily use RAII.
And then performance suffers [extra code for constructors and destructors
and then the try / catch]. And all of that complexity for what?
christos
More information about the bind10-dev
mailing list