Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127259 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 500181A00BC for ; Thu, 1 May 2025 02:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746065809; bh=EoSuT0eIZzhmgLEz9oES/QMhba98BF5NWOJm6sTDIrM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=E27fxgwyICHzwk9D/MxrZUFPCiBIm+z/OJtgmriLshWhcYukGMEDh0yGZQLheoDht awFYDutMbKm9SGBpL0y5fBj7M52jg94Uhz8ucfFZ8Qoo72XxPnRpUoLv/pjtiWjkfq Mkpx3fq+nM750QlR1dzQ6z11cnA0R0x+SoI07hQ1VCyJ76E+qF9aSXJZBIWZxcmPiA GwF5DEMOJQRTp+qMgZhO9ApsmiTMJ9n0CXH4XjVCyQ0iHI+L+Sk8fU3LKzKdp1tnMP Atpx1OK/EX04D6DwJzGk0+l0SrpbqpF/MCNdfVX8MOfKeVendSeKzTM4n4qf6xw4BO sWfExZwgI1OYg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49B22180087 for ; Thu, 1 May 2025 02:16:47 +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=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS 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 gavin.smtp.mailx.hosts.net.nz (gavin.smtp.mailx.hosts.net.nz [43.245.52.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) 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 02:16:46 +0000 (UTC) Received: from 222-153-185-98-fibre.sparkbb.co.nz ([222.153.185.98] helo=[192.168.1.67]) by gavin.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1uAJVo-0045tk-1n for internals@lists.php.net; Thu, 01 May 2025 14:18:56 +1200 Message-ID: <8a102929-9abb-446c-ad75-4c6694600f8f@varteg.nz> Date: Thu, 1 May 2025 14:18:48 +1200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Concept: Lightweight error channels To: internals@lists.php.net References: <39597a9c-6854-40c6-a529-32b2b178cb27@app.fastmail.com> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Hosts-DKIM-Check: none From: Weedpacket@varteg.nz (Morgan) 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).