Optional catch binding

From: Date: Thu, 21 Feb 2019 15:27:40 +0000
Subject: Optional catch binding
Groups: php.internals 
Request: Send a blank email to internals+get-104491@lists.php.net to get a copy of this message
Hi Internals, I'd like to propose an idea to allow catching exceptions by type only, or globally, by any type. In case the "$e" variable or the exception type is redundant, it doesn't need to be specified: try { x(); } catch (\Throwable) { // ... } try { x(); } catch { // ... } Example in the wild that could benefit from this: https://github.com/symfony/symfony/blob/5a3e8942032c1a49496fe8db61828707b45442f9/src/Symfony/Component/Config/Definition/ArrayNode.php#L247 ($e variable is redundant). Allthough global exception catching might not be a good practice per se, I don't see a real reason to forbid it. However, these are 2 independent features that can be voted for I guess. For now, I'm aiming to get rid of "unused variable $e". Thoughts? See also - https://nitayneeman.com/posts/a-taste-from-ecmascript-2019/#optional-catch-binding - https://en.cppreference.com/w/cpp/language/try_catch Cheers, Roland Franssen PS: 3rd attempt, sorry if im spamming somehow

« previous php.internals (#104491) next »