Date: 08/31/00
- Next message: Zeev Suraski: "Re: [PHP-DEV] backtrace"
- Previous message: Nels Lindquist: "[PHP-DEV] Re: PHP 4.0 Bug #5906 Updated: PHP 4.0RC2 or higher with CLibPDF fails to compile on RedHat 5.2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 19:26 31-08-00, Wez Furlong wrote:
>$db->locktable("ATable");
>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 ...
>}
How about simply:
try {
... 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 <email protected>> http://www.zend.com/-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Zeev Suraski: "Re: [PHP-DEV] backtrace"
- Previous message: Nels Lindquist: "[PHP-DEV] Re: PHP 4.0 Bug #5906 Updated: PHP 4.0RC2 or higher with CLibPDF fails to compile on RedHat 5.2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

