> Le 11 oct. 2019 à 13:05, Nikita Popov <nikita....@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 of `exit`, which is quite akin an early `return` 
in a function. Therefore:

* Executing finally blocks (as does an early `return`) would be an improvement.

* But intercepting it in a `catch` block or in an exception handler, is usually 
unwanted, contrarily to everything that currently implements `Throwable`.

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

Reply via email to