Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113409 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12655 invoked from network); 6 Mar 2021 18:09:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Mar 2021 18:09:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B68D1804DD for ; Sat, 6 Mar 2021 10:01:13 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 6 Mar 2021 10:01:12 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 265D81F44 for ; Sat, 6 Mar 2021 13:01:11 -0500 (EST) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Sat, 06 Mar 2021 13:01:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=hSZRmV g0s/acEekEaVU/7kPuzVaRUpDJ+bBSLoZSrzc=; b=MjgOLeRIIBtXZAGSqiSRor QBYVkYLNAMRpPEktEqsxgoPbItJ10K/Bxa/QYKpZ34/gYKsB6T7XvC0g7hLIySgL nfDNlOfyZZ+IwLxBCxbrQMmbAgy5TK/MiXMNCNlbeLrh7an93XvsFqQAcXRbqHRN T1mAhBMfV9BiHcQtYH4w8N3+FARBGFrlzuT9AJ4bx9c03Fn4qnPGu3Wt3tK3326O /kI/TVsH2mc9pBvTunPlqm0MOSPSHUPxzuRZ65wLFBQY+rCXUxalvh6RToeiEemt 0KqoMaZ/WoKVZgYt2BFVj5s3LalAyvnPTXomSOVcn9pbYc6gWpKUAA+vKAA2qaJA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddtkedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgfeufedtjeeludfftedvvdffjeefheegkeffudeu hedthffgfedtffehteetjeevnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehg rghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6B1FE3A02E5; Sat, 6 Mar 2021 13:01:10 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-206-g078a48fda5-fm-20210226.001-g078a48fd Mime-Version: 1.0 Message-ID: <90cd28fd-f331-4f19-844b-4b03c2e7b0a8@www.fastmail.com> In-Reply-To: References: Date: Sat, 06 Mar 2021 12:00:50 -0600 To: "php internals" Content-Type: text/plain Subject: =?UTF-8?Q?Re:_[PHP-DEV]_[RFC]_Extend_error_control_operator_to_suppress_?= =?UTF-8?Q?exceptions?= From: larry@garfieldtech.com ("Larry Garfield") On Thu, Mar 4, 2021, at 8:08 AM, G. P. B. wrote: > Hello internals, > > This new RFC which I'm proposing is to extend the capability of the error > control operator @ to not just suppress diagnostic messages but also > exceptions. > It can currently be found on GitHub: [1] > https://github.com/Girgias/error-control-operator-exceptions-rfc > > The main motivation for this is to provide a path to migrate in a backwards > compatible manner away from diagnostics such as E_WARNING to the use of > exceptions without breaking 99% of PHP code which has been written in the > last 25years. > > This proposal on it's own would not be sufficient to trigger such a change > for extensions but in combination with another proposal to introduce a > `throw_on_error` declare [2] it could provide a bridge for a gradual > transition to the use of more exceptions internally. > > Although I'm not thrilled with the idea of shoving more functionality into > @ I don't see any other way, and thus I think it a necessary evil to > improve the long term health of the PHP project. > > Feedback on this RFC and different ideas on how to tackle this topic are > highly appreciated and welcomed. > > Best regards, > > George P. Banyard > > [1] https://github.com/Girgias/error-control-operator-exceptions-rfc > [2] Draft RFC for throw_on_error declare > https://github.com/Girgias/php-rfc-throw-on-error-declare My first thought is that if you're throwing away exceptions, you're therefore performing an expensive operation (generating a backtrace for the exception) that will then be discarded, and thus is wasted effort. If people start using this frequently as a short-hand that allows exceptions as a bail-out flow contrl (whether that's good or bad, overall), that means you could end up with unexpectedly slow code that generates lots of expensive exceptions for no purpose. My first thought would be to ask if it's possible to set some contextual flag when @ is used, such that code executed in that scope will not generate a backtrace and instead throw some kind of thin exception that has only the cheap bits in it, making it less expensive. Of course, I realize that may also end up encouraging people to use exceptions for flow control, which is not ideal. Basically, my concern is that making this too easy to do: $val = @<\Throwable> something() ?? 0; will hide some nasty and hard to resolve performance bugs if something() ends up throwing a lot as a matter of course. --Larry Garfield