[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Those dern C++ exceptions
From:       Herbert.Graeber () t-online ! de (Herbert Graeber)
Date:       2001-08-15 21:12:05
[Download RAW message or body]

On Wednesday, 15. August 2001 18:18, Guillaume Laurent wrote:
> On Wednesday 15 August 2001 16:57, Adriaan de Groot wrote:
> > Here's the URL, and that combined with Waldo's sage words should
> > convince, well, some people:
> >
> > http://cseng.aw.com/book/related/0,3833,020163371X+11,00.html
>
> Basically this guy says that exception-safety is hard, and he's perfectly
> right. Nothing new about that. He doesn't say that exceptions sucks or are
> a stupid idea, just that using them isn't trivial.

No, exceptions aren't a stupid idea. Much of the overhead will go away, 
because you haven't to check the result of every function called. (Currently 
ther are many functions calls, that are completely unchecked, expecially 
constructors, that have not return value to check).

But using exceptions isn't trivial. I am using exceptions in my (Non-KDE-) 
code and discovered that exceptions are a all or nothing thing. Especially 
frameworks like QT or QT+KDE must be exception save., else you will suffer 
from a big overhead, because you must handle every exception to not fall 
through into the framework.

If QT and KDE can handle exceptions themself the overhead will be reduced. 

> I have a suggestion : take this Stack class, and make it report or handle
> errors without using exceptions. Then try to imagine what it would be like
> to use that in an non-toy project.

Yes, using exceptions is the only way to handle errors in constructors. 
Errors in destructors are a problem even with exception handling, but not as 
muich as without it. Imagine you must check for every push or pop, if it 
succeds or not. With exception handling you haven't to check the result of 
every single function directly after it has been called. YOu can concentrate 
on the control flow that happens when everything goes well, instead of 
cluttering all your code with checks.

Summary: Exception handling is a good thing if use right, but I don't see 
exceptions in KDE before QT4 (supposed it is exception save).

Cheers,
Herbert
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic