Re: [RFC] Supports 'finally' keyword for PHP exceptions

From: Date: Tue, 24 Jul 2012 17:33:54 +0000
Subject: Re: [RFC] Supports 'finally' keyword for PHP exceptions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 24/07/12 18:31, Stas Malyshev wrote:
Hi!
In particular this means that... ... if a die() is execute somewhere in the try clause (or a called function) the finally clause must still be run. ... if a parse error or other fatal error occurs in the try clause (or called function) the finally clause must still be run. ... if the user interrupts the process the finally clause must still be run.
No I don't think so. finally clause is used to clean up resources allocated/initialized by the code inside try clause. All the above functions will terminate the script and thus all the resources that were allocated will be freed. If you so something more persistent, then a) use shutdown functions b) know that the script can be killed at any moment anyway, so PHP can not guarantee you anything. I don't see how finally ever implied it would be called on die().
Basically this requires that all of the actions that are currently fatal need to be converted to exceptions. E.g. Python has special SystemExit and KeyboardInterrupt exceptions, as well as SyntaxError and so on.
So basically this requires that PHP will be converted to Python. ;) I'd almost write an RFC but then I remembered somebody already wrote Python! :) PHP risks losing some of its uniqueness to fixing things, unfortunately. But losing bad features and moving forward is good, right?
-- Andrew Faulds http://ajf.me/

Thread (34 messages)

« previous php.internals (#61704) next »