Re: exit() via exception
| From: | Thomas Lamy | Date: | Sun, 13 Oct 2019 10:09:21 +0000 |
| Subject: | Re: exit() via exception | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107528@lists.php.net to get a copy of this message | ||
Am 11.10.19 um 15:16 schrieb Claude Pache:
This! +1 TomLe 11 oct. 2019 à 13:05, Nikita Popov <nikita.ppv@gmail.com> a écrit : I'm mainly wondering how exactly we'd go about integrating this in the existing exception hierarchy. Assuming that it is desirable to allow people to actually catch this exception, my first thought would be along these lines: Throwable (convert to abstract class) \-> Exception \-> Error \-> ExitThrowable This does mean though that existing code using catch(Throwable) is going to catch exit()s as well. This can be avoided by introducing *yet another* super-class/interface above Throwable, which is something I'd rather avoid.We should keep the semantics ofexit, which is quite akin an earlyreturnin a function. Therefore: * Executing finally blocks (as does an earlyreturn) would be an improvement. * But intercepting it in acatchblock or in an exception handler, is usually unwanted, contrarily to everything that currently implementsThrowable. But if you do want to allow exit signals to be caught in catch blocks, there is no absolute necessity to introduce yet another superclass or superinterface, because you can write (since PHP 7.1): catch (\Throwable | \ExitSignal $e) —Claude