Re: [RFC] Optional Catch Block Body
| From: | Mihail Liahimov | Date: | Thu, 31 Jul 2025 07:02:42 +0000 |
| Subject: | Re: [RFC] Optional Catch Block Body | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128328@lists.php.net to get a copy of this message | ||
Hello, Alexandre.
I've heard your concerns, but I don't think this proposal will encourage
other developers to ignore exceptions more often. Basically, even now,
nothing can stop a developer from ignoring exceptions. He can simply leave
the body of the capture block empty. And in this RFC is proposed just to
allow not to write extra brackets {}.
If we talk from the point of view of bad practices and applicability, then
the same nullsafe operator may encourage developers to check for null less
often. And this leads to problems, I personally observed this.
It seems to me that the issue of bad and good practices should be the
responsibility of developers. A programming language is just a tool. And
there are many ways in which it can be "badly" applied.
чт, 31 июл. 2025 г. в 11:51, Alexandre Daubois <alex.daubois+php@gmail.com>:
> > Of course, empty catch blocks are bad practice in most cases. But this
> particular proposal is not intended to encourage these bad practices. I'm
> just suggesting that you don't have to write an extra boiler plate at the
> syntax level in situations where it's necessary.
>
> From what I can tell, it's very rare to have empty catch blocks, and
> even more being done rightfully. I'd be very suspicious if I came
> across such code.
>
> I think the extra boilerplate is actually a good thing, showing the
> explicit intent to not catch the error. I get that the proposal is not
> intended to encourage such a thing, but I agree with Ayesh: it would
> definitely will.
>