Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3757 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62527 invoked from network); 6 Aug 2003 07:55:40 -0000 Received: from unknown (HELO flock1.newmail.ru) (212.48.140.157) by pb1.pair.com with SMTP; 6 Aug 2003 07:55:40 -0000 Received: (qmail 5383 invoked from network); 6 Aug 2003 07:55:20 -0000 Received: from unknown (HELO JUNGLE) (xi.newmail.ru@217.118.74.9) by smtpd.newmail.ru with SMTP; 6 Aug 2003 07:55:20 -0000 Date: Wed, 6 Aug 2003 14:56:51 +0600 X-Mailer: The Bat! (v1.62q) Personal Reply-To: Simeon Koptelov X-Priority: 3 (Normal) Message-ID: <759544336.20030806145651@newmail.ru> To: internals@lists.php.net In-Reply-To: <85567616.20030806091410@post.rwth-aachen.de> References: <20030806001540.7978.qmail@pb1.pair.com> <85567616.20030806091410@post.rwth-aachen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re[2]: [PHP-DEV] try/catch/FINALLY From: xi@newmail.ru (Simeon Koptelov) 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