RE: [PHP-DEV] try..catch and finally
| From: | Zeev Suraski | Date: | Thu, 31 Aug 2000 17:12:20 +0000 |
| Subject: | RE: [PHP-DEV] try..catch and finally | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-31470@lists.php.net to get a copy of this message | ||
At 19:26 31-08-00, Wez Furlong wrote:
$db->locktable("ATable");How about simply: try {try { ... modify contents ...} finally {/* always executed */ $db->unlocktable("ATable");} is nicer (and more maintainable) than $db->locktable("ATable");try { ... modify contents ... $db->unlocktable("ATable"); ... loads of cleanup code here ...}catch($exception) { $db->unlocktable("ATable"); ... loads of cleanup code the same as above here ...}
... modify contents ...} catch {
... any error recovery code here ...} ... cleanup code ... We're mostly gearing try..catch to allow users to handle errors, not perform cleanups.
I understand if you don't implement a "finally" mechanism right away, but I urge you to keep it in mind while writing the try..catch code; maybe someday there will be hundreds of people asking for "finally" :-)We're not even implementing try..catch right away, let alone try..finally :) Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/