Re: [VOTE] Catching Multiple Exception Types
| From: | Bishop Bettini | Date: | Tue, 19 Apr 2016 00:42:58 +0000 |
| Subject: | Re: [VOTE] Catching Multiple Exception Types | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92433@lists.php.net to get a copy of this message | ||
On Mon, Apr 18, 2016 at 9:40 AM, Marco Pivetta <ocramius@gmail.com> wrote:
>
> I voted "NO" due to previous discussion. TL;DR: this is FAR off the 80/20
> use-case for a language syntax change.
>
> ...
> These 3 exceptions usually result in separate handling anyway. If same
> handling is needed, you can as usual extract a private method (if you are
> in a class) and deal with it there:
>
> ...
> Still, even in this case, I'd flag it up in a code review, as same handling
> for 3 different exception types generally (not always) means something is
> really wrong.
>
> So we are building a feature for a 1% case that, while simple to implement
> at parser-level in PHP, requires changes in all userland libraries that do
> parsing or rely on the AST.
>
I agree: the times this need arises are relatively rare, and in those cases
functional encapsulation cleanly handles the repetition. I would vote no,
were it not for one thing: union types
<https://wiki.php.net/rfc/union_types>.
catch constitutes a formal signature, exactly like a function signature. In
my mind, this proposal and the union types proposal are intrinsically tied.
If we have one, we must have the other. If not, we're inducing a sadness.
Since I do see the need for union types, and since I believe the two must
be accepted or rejected together, I voted yes.