Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104491 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30941 invoked from network); 21 Feb 2019 19:10:23 -0000 Received: from unknown (HELO mail-ot1-f44.google.com) (209.85.210.44) by pb1.pair.com with SMTP; 21 Feb 2019 19:10:23 -0000 Received: by mail-ot1-f44.google.com with SMTP id t7so28889250otk.8 for ; Thu, 21 Feb 2019 07:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=D2F8b25y9dVfRIj/mH4IqzrDrkj5case08i3156wIts=; b=qrnlbpJaIAAxE4ujR/WD7B9VQlvWYBeYF+2L27ztxqMQOH3iVtuK26Dck3GB4AMZDx fxhMc6p7x16VlRwRR5T2QVemCk8qz9nCuOUxeTun+W22twjc+uA57XTV3TfBqfkJhE7Y IW4uiVoO8bJ0ENFj+bGqnt/RY3Aw8dKVQEGEdbpBp3ZIde1yB9NMFmu/KbaHRyHSl5Ko lD5IuHkjlg+GOBpexUk8xDnspeEgEMjc+babOLO+hnUBW8CaF4Gz+fnbcH7VhXfQGAci 3ozECYQrhD/QzDCYWQNaEPeRhzaxNkxbA11PRBudxT6Crez8/MwCjZz/bX5gBqhiwNHl MXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=D2F8b25y9dVfRIj/mH4IqzrDrkj5case08i3156wIts=; b=rxcv6zCRuX0ycUwjoX0L4o9PRLtGBu44J6NMtR5M+qgwg+eJFg1oNRGMjzmCiqIi1t pztBOXyCcdCUmPpg+2mUUnbc4pUCceWf48dd7J4UT+erhCqOVvNi9tQgm5295QOfU+C9 g3yIDBUl9AW0/Jk43I2t+Y43VKA6KouR5pxHTzACtAot7XeYYkmQyjcYjyWWIu2AyBlG eC/BMKQ/ECYmD0Wwfh5aFW/5NrF9BA0399IU+naY1UzIXe2Rxcr2xDpj+o54YRAk/eC9 sZtqODkqZOvy7FXou3KalP0I4jj+ij5PRFXbGcas8nIa9D9KEY3zF4yvoo5UjtEECWZx 5g2A== X-Gm-Message-State: AHQUAubB/bN4uGyJqpVXGM5Hq2nSrfuKSQTza0vHAkto+xeNi/s21Fhr O6JhSpVlBlJAjtIIEcl1EmY+uj4rPFCsPfQWHL3HVJ8R X-Google-Smtp-Source: AHgI3IZDnELeKp9wsFPeerS6d0NmLgCtNo0ZCsn9AmiSqUCIP5/eK/eerUu0uMtx+nBTzToyJBqlcwZt9rRddZHCkJ8= X-Received: by 2002:a9d:4799:: with SMTP id b25mr25624305otf.294.1550762871099; Thu, 21 Feb 2019 07:27:51 -0800 (PST) MIME-Version: 1.0 Date: Thu, 21 Feb 2019 16:27:40 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001017d30582691e7b" Subject: Optional catch binding From: franssen.roland@gmail.com (Roland Franssen) --0000000000001017d30582691e7b Content-Type: text/plain; charset="UTF-8" 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 --0000000000001017d30582691e7b--