Re: [RFC] Transform exit() from a language construct into a standard function
| From: | Gina P. Banyard | Date: | Tue, 28 May 2024 11:58:43 +0000 |
| Subject: | Re: [RFC] Transform exit() from a language construct into a standard function | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123444@lists.php.net to get a copy of this message | ||
On Tuesday, 28 May 2024 at 07:53, Daikaras <webmaster@daikaras.lt> wrote:
>
> I feel like the reasoning in this RFC is misguided.
exit
> behavior is
> not consistent with functions because it is not a function. But it is
> consistent with constructs like echo. Or am I wrong? I'm
> all for
> stricter typing but not at a cost of reliability. exit IMO
> should
> always terminate script, no exceptions (no pun intended :)). Otherwise,
> it may have security implications in some codebases, as Saki pointed
> out. So I'd rather have it error fatally like for example
> break does
> when passed non-integers. And on the same note maybe syntax could be
> improved to not require parentheses when passing the code (so exit
> 0; would be valid) since it seems to be the cause of the confusion.
>
> Just my 2c.
>
> p.s. In B/C table you should mention that passing Stringable objects
> will throw TypeError when strict_types are enabled.
This is not the cause of my confusion.
If you had read the RFC carefully, you would have seen that exit() already throws a TypeError that
can be caught if you pass in a non-stringable object.
So the argument that it should always exit is invalid.
Moreover, in other programming languages exit() is a function, and I don't see a reason for
having something be a language construct when there is no need for it.
Best regards,
Gina P. Banyard