[RFC] Supports 'finally' keyword for PHP exceptions
| From: | Sebastian Krebs | Date: | Tue, 24 Jul 2012 11:56:53 +0000 |
| Subject: | [RFC] Supports 'finally' keyword for PHP exceptions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-61677@lists.php.net to get a copy of this message | ||
Sorry ... to the list instead.
---------- Forwarded message ----------
From: Sebastian Krebs <krebs.seb@gmail.com>
Date: 2012/7/24
Subject: Re: [PHP-DEV] [RFC] Supports 'finally' keyword for PHP exceptions
To: Laruence <laruence@php.net>
Hi,
2012/7/24 Laruence <laruence@php.net>
> On Tue, Jul 24, 2012 at 7:41 PM, Alexey Zakhlestin <indeyets@gmail.com>
> wrote:
> >
> > On 24.07.2012, at 15:20, Laruence wrote:
> >
> >> Hi:
> >> As the previous threads disscussed, I make a implemention.
> >>
> >> here is the RFC: https://wiki.php.net/rfc/finally
> >>
> >> any suggestions?
> >
> > Will it work without "catch" in your implementation?
> nope for now.
>
> but if it is needed, I can implemente it
>
It is. 'catch()' usually means "I can handle it (at least partially)", but
when 'finally' it just means, that the current scop wants to clean up ;)
Additional I see myself already, that I "misuse" it like
$f = fopen($file, 'r+b');
try {
return search_in_file($f);
} finally {
fclose($f);
}
What I mean: I see myself already using 'finally' without ever expecting an
exception, just because it feels so easy to never forget anymore to cleanup
resources. Is this intentionally?
Regards,
Sebastian
>
> thanks
> >
> > try {
> > doSomethingDangerous();
> > } finally {
> > doCleanup();
> > }
>
>
>
> --
> Laruence Xinchen Hui
> http://www.laruence.com/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>