Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130785 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 180161A00BC for ; Wed, 6 May 2026 16:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1778084403; bh=N7qfcimteWNwtzqogjjdXvEV7irUFfsJyjnjFnDUZ7I=; h=Date:From:To:In-Reply-To:References:Subject:From; b=I3YRi2i+v30TLQDHJVYYYjHwfrsJoGqHAlnZk4+Iqsx4/YksZ+Zhk3TnidD66YZBh JyiwQcap6zAFMbap5kRLO+vYW6ipNFN2KtRZI9uk6IgxuwdUmXDj1pbbiyAVhIfMBF vdWSEjCwky61SVR3oBPkLVzLbH4dx7hdr+U9VxTUKQMfqdlu6n5MDKSAMC0OBgi+zo Z7zuEGY8qMVtcC2nfYvLqDTWTIH7J3D2LlowlmcPGjau7oulHQ9pnna5LSQCS1JCHw 9qkJPy7Tao5Gz5EdhVF7/xSzMVs0f3bzr84SYJqRY9XaHn7ApD1tSwI2LLtNRbJ/E2 nE3J8Y9erdDYQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AEC39180062 for ; Wed, 6 May 2026 16:20:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,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.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 ; Wed, 6 May 2026 16:20:02 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id E44881D0019C for ; Wed, 6 May 2026 12:19:56 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Wed, 06 May 2026 12:19: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=1778084396; x=1778170796; bh=PQ72WXtOvXGYxnsSxAJjb BPZJ5p1ZPirOC6eWG3vjQI=; b=NJL7SGQVtc7Ae8Ty0sumXYRun550Sln+YKs8H ZPjS1aX7kx8ubaVNO0PhX8jGggW/QI4rrrUGr5W405C7+gDHVk15vSDXEPuc7uzn Fm8VuvxAnCgICS+5Mxh9dZmogCh8/qFCx7OhEYlA5rR3TI4S5zZbZ4aJpBdMpJMj UQes07fiwZSjO7h/EXn3c5afb+neLcGuTxVvDHmEGUZYDSD8mLsZY44Q2gmzdyQn YftDinkOVtMSYEIFSpKk51LcJviSyrnWWCz/6j/4j3kkpi0/WiB4BwQqHwyMOTpX ekks7aazvPcbhB20IKwdCA/SXx9HPasPJQNDjelbrGHEQD3yQ== 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=1778084396; x=1778170796; bh=P Q72WXtOvXGYxnsSxAJjbBPZJ5p1ZPirOC6eWG3vjQI=; b=PFMRPfkNwvLrazvTi GzHhmjE5yFxThJSeoDVseuRl2lRz34WhYlliPulQOt9WrdP53XVxxK4bMV9Kcuxn 11sRuJ4igNmkAjUjl4YSOfN6ciKkCIcc27GZgxChexZIiqjUtA3ztCpkU6rT9QPn 8b6fLc1LLPpwqI3aQzmj8ceF+3ADswvBb1h+8pvy3GIzDxquky8T2t1N2Mx0cKSt lhVR3NRgrovkbMuSCy3Q/XeSDGYqQUuxtVkyqpuWGS9ctw7GM0kNmniHVNwfEF5v iAey5E0R1GTxDH4M0iBwmI5qiQorRHmfnl3E7Xc5x2gJNne8G5K13JhRkAH9dvzA tY3YA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddutdehtdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeet udeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1EC90700069; Wed, 6 May 2026 12:19:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Atmh9k-BTBuN Date: Wed, 06 May 2026 11:19:35 -0500 To: "php internals" Message-ID: In-Reply-To: References: <4985896b-c80a-4302-912e-9f572a260fb5@app.fastmail.com> <88716CA9-38E4-45CA-9471-2D8928CF4DE2@rwec.co.uk> <3b2b863d-d179-40c9-ad26-8605e854a331@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, May 6, 2026, at 8:31 AM, C=C3=B4me Chilliet wrote: > Le 22 avril 2026 20:28:15 GMT+02:00, Larry Garfield=20 > a =C3=A9crit=C2=A0: >>I will stop here, however, and ask for input from the audience. (Not = just the regulars in this thread of late, but all of you reading this.) = Including if you have an alternate approach to the three listed above t= hat would have notably fewer cons. >> >>--Larry Garfield > > I prefer the void return and throw if needed approach, it looks way=20 > more understandable. I was confused by that part when reading the RFC=20 > and really surprised that returning an Throwable on success is ignored= ,=20 > which is not clear at all when reading the interface. By which you mean the "if you do nothing, the exception is swallowed" ap= proach? (IE, more work in the common case.) My reluctance there is that it will become really easy to forget to prop= agate. public function exitContext(?Throwable $e) { fclose($this->fp); } That seems like it should be all you need, but it will also silently swa= llow any errors, so whatever code uses this context manager won't know i= f it was successful or not. That seems not-great to me. > The in-out parameter works too but is a bit weirder, and makes it=20 > unclear what happens if exitContext throws. > > It's also unclear to me in the current desugarized version what happen= s=20 > when exitContext throws, the reset of the context var does not happen = ?=20 > There is nothing to handle that. > > Co=CC=82me We'll have to clean up the desugared versions once we decide what they s= hould actually be. :-) There's probably a bug in there at the moment. --Larry Garfield