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

List:       kde-devel
Subject:    Re: OT: Re: Those dern C++ exceptions
From:       Herbert.Graeber () t-online ! de (Herbert Graeber)
Date:       2001-08-20 19:29:45
[Download RAW message or body]

On Monday, 20. August 2001 11:09, Lubos Lunak wrote:
> [snip]
>
>  void stuff()
>     {
>     try
>         {
>         some_simple_smart_ptr< Foo > foo = new Foo();
> 	// Do stuff with foo that might throw an exception
>         }
>     }

You even don't need a try. BTW, ther is not try without a catch in C++:

  void stuff() {
       some_simple_smart_ptr< Foo > foo = new Foo();
       // Do stuff with foo that might throw an exception
  }

>  As your punishment, you'll write 100 times 'acquiring resources is
> initialization' :)) . Hmm, this reminds me, I wanted to send a mail about
> smart pointers to kde-devel few months ago ... maybe I should do so.

Right, you should have done that.

With technique one can eliminate 90% or more of all catch'es. Because you 
don't need much explicit checks written code becomes much shorter and easier 
to understand (assuming you are familar with exceptions). I am sure that the 
unnecessary explicit error checks at least partially outweighs the additional 
overhead the compiler introduces for exception handling.

A QT and KDE with full support and use of exception handling would be a great 
thing, but I fear that this will not happen soon.

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