Re: [RFC] Supports 'finally' keyword for PHP exceptions
| From: | Rasmus Lerdorf | Date: | Tue, 24 Jul 2012 17:20:32 +0000 |
| Subject: | Re: [RFC] Supports 'finally' keyword for PHP exceptions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-61699@lists.php.net to get a copy of this message | ||
On 07/24/2012 10:01 AM, Nikita Popov wrote:
> Another, separate point against finally is that in PHP (unlike many
> other languages) most (all?) built-in resources clean up after
> themselves. So if you open a file you don't have to worry about
> closing it again. It'll do that all by itself as soon as it goes out
> of scope. The same applies to database handles, etc. As PHP uses
> refcount based garbage collection the resource is actually cleaned up
> right away, not just at the next GC run (which could be problematic if
> you open up many files in a row).
Which is the argument for why finally doesn't need to worry about the
fatal-error case. Most resources are cleaned up on a fatal already,
including your lock example, so it isn't an issue. finally is
exception-level for intra-app cleanup, not for request shutdown cleanup.
We already have shutdown functions for that case.
-Rasmus