Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127261 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 60FB21A00BC for ; Thu, 1 May 2025 13:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746106224; bh=fpWZjvEZK7/hg/DLzHrsUFI46scSQNsxQ9ZCvmL4spo=; h=Date:From:To:In-Reply-To:References:Subject:From; b=h89RyRuugMGN5Kh64s4dCtRQXV7zDqG07CR7lXHZCpCiH+3sfQvf3a7ml7mRPxP0s FMWF8QjDE+1uj7ZEXh+Wxf18cVpnAecAMnaLtxNCVz2LgVwtJPJFTrmjN26ffZHImS elQZ1hHobdvcKoPqC83vL+6zXJg2EkrWr5yfFQeDwHzfu/cEAfgWUaGcPo/Xr2mSF5 Ct7ScXHb3kM335MXLszRHJ9QSCBsbO0zf3jZGL719+x9V4DdEN2nxwS05+TqZeeq98 aqeh0R9hm4CtQZax5tGLpkdCHbMeK1+06O6bz0wasJSwC1oBcrDoYXngUTKVSecSJ/ lwy9lCMAbvGkA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C1BB18003B for ; Thu, 1 May 2025 13:30:22 +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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) (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 ; Thu, 1 May 2025 13:30:22 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id CC6CB1140211 for ; Thu, 1 May 2025 09:32:37 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-10.internal (MEProxy); Thu, 01 May 2025 09:32:37 -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=1746106357; x=1746192757; bh=phuUGDengmbYiCMW0oSom PNhumRAm0xb5xJr31eb2YE=; b=asJx6D/FW9Ao1s5H8c1mURUGaapNbn8RTWnCo zjFce9E21B91ix8yg4J3XqrAyAeEiNh8ScpqvlFMtrLcnqeUwUHsH7V4Am6zJ7NU /JU0UHh6mbyldQIcXH0rC8IF8bkjUwqHJAl41uc4qfSdgPz1oJT5tK3SoryfOZHo 5AQrwGVqjeP5Q1rGJHOc7ZlndVsju5DyLWM8Jjaf/oXywQNfZkX8141oYJRWQgbr soJCi69Qy8On4col2mZP+Hh6yC48akZ7hqQiJrFgVQM5FTS2MI3XeN0nEv6Oo/yW e1l2tjnHRJLytLlJbk1tr0GQsJb74SpVZ08jFIIp0zW6NvijQ== 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=1746106357; x=1746192757; bh=p huUGDengmbYiCMW0oSomPNhumRAm0xb5xJr31eb2YE=; b=viIcSBS8/MwQp5WGT JxrbLa86kzcqlFKFATgOqId9jH2n3QSUlLGEiaAFB205/Q4UmppAdBuFOBnSfg0t URK29EHohvzb3hAc0Rw/E6IsuF8Y8wRS7MvkGcqa6ZJ6Mxve0oYqczp2cal/RGpW lVYxkCPXjKr4Npi8TN5LwEz6AfUjtg8en7neFXEny5Fax59ofkhcMnFHsZ0cevXU E+1H4vzb1zkAwfP4pBYyK8m7NMO8jiKbyiZYFUcQwd0IAv359tlO4MhKsnmuwqHL O9/ilvPXXWWO4GP2vbLZpOHqHLrqw16JbJptZRmlvxm4esr2STDZuw+Z1Rknk6yx 5qDjw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeljeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredt tdenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpedugedvlefgueegheef jeetffduveeltefhfeegjeffffelgedttdevkeegkedugfenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 34EA229C0075; Thu, 1 May 2025 09:32:37 -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: Thu, 01 May 2025 08:32:16 -0500 To: "php internals" Message-ID: <043e42a9-c471-4b3a-b900-64c9f72066e0@app.fastmail.com> In-Reply-To: <8a102929-9abb-446c-ad75-4c6694600f8f@varteg.nz> References: <39597a9c-6854-40c6-a529-32b2b178cb27@app.fastmail.com> <8a102929-9abb-446c-ad75-4c6694600f8f@varteg.nz> Subject: Re: [PHP-DEV] Concept: Lightweight error channels Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Apr 30, 2025, at 9:18 PM, Morgan wrote: > On 2025-04-28 06:06, Larry Garfield wrote: >> Which is why I think we do want some kind of syntax similar to Rust's ?, so the above could be shortened back to this: >> >> function doStuff($id): string raises UserErr { >> $user = $repo->getUser($id) reraise; >> // We have a good user. >> } > > One thing about Rust's ?, compared with an additional "reraise" keyword > thingy, is that the former is inline with the rest of the expression > while the latter forces a distinct statement for each possible failure > point. The "happy path" no longer looks quite so happy. > > In other words, Rust's approach looks syntactically a lot more like > PHP's "?->" nullsafe access, which can be looked on as addressing the > specific case of "returning null to indicate failure" approach to error > handling (in the even more specific case where the happy path would have > returned an object). One of the related ideas I had (but omitted from the initial post for brevity) was to require error objects to implement a new marker interface, which would cause the object to behave like null as far as nullsafe operators were concerned. Or possibly some other set of operators, I'm not sure. But some way to allow error objects to behave differently in a convenient way. (This is the sort of thing I've not worked out yet because I don't know if it's worth it.) --Larry Garfield