Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127226 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 4E04B1A00BC for ; Mon, 28 Apr 2025 19:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745867981; bh=wlyaqgsx6bVPF1Fs+hrxL5z+2xIrbwMtE0lkKiAYv5k=; h=Date:From:To:In-Reply-To:References:Subject:From; b=QlH6hlgYloiNLtiuO9EBikiqjKT/BfysJsjGi+ZaQs52EtbwVJHwYgDGDn+Xg6WiV RN1RM7S/nuj/PrzWz4c7efQuU+cosIhPc/wzjZ6ltNeYrCmVSdR6y5z6EU+4vptJxK bHopBqVlyXKKK9AfMABVdimjf86GiXUpJ79sjHcCTTVI1A4B8dzVtj3GUmuz0ypnMr u+FlJiMBRX4DTar3pmNenxhD+MuX5RdxykZkLxfv5NghYWOiUdfc1LXbAPFyzUZ6Fl 0f0hl3xu+Nn6P3RpjkmZJOiPtFc72Osif020JalMzgawMn95H6TcWuAEgkd2+N6sMx NSgwYO1m4zrxA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 198E8180086 for ; Mon, 28 Apr 2025 19:19:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 28 Apr 2025 19:19:39 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4C62011401BD for ; Mon, 28 Apr 2025 15:21:56 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-10.internal (MEProxy); Mon, 28 Apr 2025 15:21:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1745868116; x=1745954516; bh=xhTjuLfA7/zLGHU3o0VY6 U9Xluz7RsiaVKY/Ov1m5MY=; b=QnWDx/tfsU/H56sytQrJrUNW3OjMw2w2yWjSy D4OSeLXg/brgBhBhBL+ATGDuCIuGmuOHrVAG16bBbhHEdtnnPkHG7/NyXzxwtykE uD9CeFSqxIoYEY9WfKbDq1ZJYSXNcD31cxXOIlkPLwabFkA9afHM9H2zxnKHGgWR wMpcGWFS2alUcYJwDN8hGoA1HvfhrXNL+x/uHwovw9cINNBOq5OHdd5A/fc116xP NMQaV3HHvrGUds8qc4/vsfK+KSSepdiFb0U1DmlnKezfaYmsLnzzyRHn2Wf210Br h4XSozDbwuo75mUSvOfU/0srqmB10qiN47LCLbGLCX5Gm3mmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1745868116; x=1745954516; bh=x hTjuLfA7/zLGHU3o0VY6U9Xluz7RsiaVKY/Ov1m5MY=; b=c4CAEMtLZho6ytNl3 KV5Flg1xh7923FHwuxI9WMReym7PpZGkQ2ykTouU5lfaSHZUdzSx5Kcf7orHLDlU kdvTZB+mR+PM2FYPZNpHpHpNmHZanuqcHgeWOZNzvJmwCPc15rSoV5/3A1c8kMqb cgHBlwaAULybuS1U2WFqX9GT0m7J4WhA/+C5cElmcYR+oYZawG0SWdhCZJGYVbLn 0YvSTeBGvzoWVJT4AMUGytuFdEa/9zTp6K817oJjohiKht0GBfbkJBhpdwixVxTg 63xGpW1g/WBFOoRo2Adg9tA6hMwg7BLlaYx4N5sG8WYQ7Ihw+rbf80oaz5rkHNhR DqYeQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddviedujeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredt jeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddt tdegteeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E1D2A29C0072; Mon, 28 Apr 2025 15:21:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T7e0f24752af1ea38 Date: Mon, 28 Apr 2025 14:21:35 -0500 To: "php internals" Message-ID: <8ba39427-bc2d-4c2a-90d8-648371e4f576@app.fastmail.com> In-Reply-To: References: <39597a9c-6854-40c6-a529-32b2b178cb27@app.fastmail.com> <150fb4df-47a4-4ab3-8edb-13e446b122cc@app.fastmail.com> Subject: Re: [PHP-DEV] Concept: Lightweight error channels Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Apr 28, 2025, at 11:28 AM, Edmond Dantes wrote: >> I have already demonstrated how it can be solved without generics. = Multiple response channels from a function already exist: Normal returns= and exceptions. Exceptions as currently designed are just very poorly = suited to the problem space I am describing. > > If another error channel is introduced, PHP would end up with *two=20 > error channels*. > This is harder to understand than the Normal returns + Exception=20 > channels + Something new. =20 > > It seems to me that this creates a bigger problem than the one it is=20 > trying to solve. =20 > > Is it possible to avoid creating two error channels and instead design=20 > an alternative handling method that would eliminate the drawbacks of=20 > the first approach? =20 > > If the performance issue is solved, are the other two problems really=20 > worth such changes? =20 > > For example, if we follow the philosophy of `RESULT`, we can say=20 > that there are two types of exception handling cases: > 1. Suppressing an exception immediately at the first level of functio= n=20 > call. Suppressing? You mean fataling. Suppressing implies ignore, which is t= he exact opposite of what I am proposing. > 2. Stack unwinding. Given the choice between: success return + error-return + the-world-is-broken vs success return + the-world-is-broken + the-world-is-broken-but-not-reall= y-so-you-have-to-handle-it The first seems substantially better, frankly. Exceptions that are sometimes checked and sometimes not is Java, which i= s exactly why everyone hates Java's exception system. > ```php > > function someFunction(): string raises SomeException { > > throw SomeException() > } > > // The backtrace is not generated:=20 > > $res =3D try someFunction() catch (SomeException) null; > > // The backtrace is generated when throw $err executed. > > $res =3D try someFunction() catch ($err) {throw $err}; > > // The backtrace is generated > > $res =3D someFunction(); > > ``` > > This kind of behavior doesn=E2=80=99t break BC, right? At the same ti= me, it=20 > allows improving PHP performance and adding contracts. The particulars there in that syntax imply the only catch handling would= be defining a different value, which may not be the desired handling. Also, that again runs into "throw may be checked or not, you don't alway= s know." It also means the exception is carrying around the extra design baggage = of exceptions. Even if the trace is elided, it's still carrying useless= metadata that would lead people astray. It also means dealing with the= constructor of Exceptions, which is notoriously annoying for extending. "Make exceptions nicer" is fundamentally not what I am proposing, nor wi= ll I propose as a solution for this space. It is the wrong approach. (= Making exceptions nicer is well and good in its own right, and I won't b= lock that, but it does not address this problem space.) It's clear you do not support what I am proposing. Good to know, thanks= . I still haven't gotten any feedback from major voters, though, so lea= ving this thread open. --Larry Garfield