[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: C++ exceptions
From: "R.F. Pels" <ruurd () tiscali ! nl>
Date: 2005-12-05 13:55:27
Message-ID: 200512051455.27772.ruurd () tiscali ! nl
[Download RAW message or body]
On Monday 5 December 2005 14.24, Matthias Granberry wrote:
> > Indeed. So show us how to rewrite the following in a clean way with
> > return codes :
> >
> > void writeFile() {
> > writeHeader();
> > writeContent();
> > writeFooter();
> > }
>
> error_t writeFile() {
> error_t err;
> if( (err = writeHeader()) || //this stops processing on the first error
> (err = writeContent()) ||
> (err = writeFooter() ) )
> return err;
> return 0;
> }
PUHLEASE! Ofcourse, the example as well as the proposed solution have
absolutely NOTHING to do with C++. Not to mention the fact I had to use my
airsickness bag when I saw the 'use-return-codes' solution.
> Having said this, exceptions are very useful in situations where the
> problem gets a little deeper or you have a more than a few levels of
> indirection present but as Thiago pointed out earlier they come with a
> price so they should be used with care.
I agree. And I think we should use them, especially if not using them gets in
the way of expressing solutions in C++. And rewriting everything into
functions returning error codes certainly does that.
--
R.F. Pels, 3e Rompert 118, 5233 AL 's-Hertogenbosch, The Netherlands
+31736414590 ruurd@tiscali.nl http://home.tiscali.nl/~ruurd
>> 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