Re[2]: [PHP-DEV] try/catch/FINALLY

From: Date: Wed, 06 Aug 2003 08:56:51 +0000
Subject: Re[2]: [PHP-DEV] try/catch/FINALLY
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-3757@lists.php.net to get a copy of this message
Hello Marcus, Wednesday, August 6, 2003, 1:14:10 PM, you wrote: CD>> What about finally ? MB> There's absolute no need for finally: MB> try { MB> } MB> catch (...) { MB> } MB> // here's you're finally code try { $this->allocateSomeResources(); throw new SomeException(); } catch( AnotherException $e ) { } finally { $this->freeSomeResource(); } This code will call freeSomeResource() -- that's why one may want to have finally. But I agree that there's no need for finally. If uncaught exception is thrown -- it's bad application design or malicious component( you cannot declare throws in function definition so some evil component can do something like " throw new ExceptionThatNobodyHandles(); // har-har-har!" . You need to refactor in first case and can do nothing in second -- if you'll start to free resources in finally after each try-catch or always catch Exception, your code will become garbage soon IMHO. -- Best regards, Simeon mailto:xi@newmail.ru

« previous php.internals (#3757) next »