Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129550 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 870C91A00BC for ; Thu, 4 Dec 2025 16:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764866815; bh=XfLci0mFc+G639Q4NfeIreQOWjCmuK0EkwBNAx29Wrk=; h=Date:From:To:In-Reply-To:References:Subject:From; b=dm02JtyCdz6jF3DeiiZUCyl1kdXvVHQVbAiIlYeBns46zFiKOewd2CEkhpoqVwfn/ pBQarV3g0K9q83Qvq/EBLDzfxAg89R3VDKO9k+qn4xsGwzgpruVgUqiXb5z/WZqKNw fs/ayKUGZ/Jo5JfFvVUFWBGeJ/EAix+MX8uB+aHr/V7RlA8m3k6ZBK8z4k4n68goSq 31oX9A5CWssZCC+zMS7EokWP8765PIVZ93c3yWBh6e7xJf/tJbU7Uf3ovkSqzLgX0M 04HuUOijdh7FYT4S5s1kWGKmXKOWoQ14A62AqlXg2sZ9Mf4oCm880usRhlkpwpCVQR e3XWfdA+/Mmiw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7680A180081 for ; Thu, 4 Dec 2025 16:46:54 +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 fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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, 4 Dec 2025 16:46:54 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id DA7FF140021B for ; Thu, 4 Dec 2025 11:46:48 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Thu, 04 Dec 2025 11:46:48 -0500 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=fm1; t=1764866808; x=1764953208; bh=3ixEVDoGdZYZihLUI9kdi Ym6fXCXq1630yVAt1pb/MQ=; b=gPM28acsOh1pdg2CkDZ4qNoVVCCiz3J2UW68t RGFx5vgOPqcvIa6GGNXtfW2SZ7GqIs0d+EYY9SAgW5/yRMd7aKo/3VenbphMIvt5 ybcWbiijvgf1rSWh8AykpdjIlLw9nHMtZEOmfr8lLugs/GdCdRP/UH2Nhe62YHzB JxMMwBokgvWsASBFSqjt4BKGJtT+RHvBn8aKQK4/L0aEk8ddT8KfSukHEv/gTq0p h6zcktR8YVUJCimOrcT829nXhkZKFr3dXq215vrSlFHfMDyR+KrStpYPoe65PfsZ yJWEJKewBNmEqlNp+aWeH0wtSlKOefye2gOvUx0I25IapzKrQ== 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=fm1; t=1764866808; x=1764953208; bh=3 ixEVDoGdZYZihLUI9kdiYm6fXCXq1630yVAt1pb/MQ=; b=cu4qtiz0YjBscbalb oj2KeBUh3e7GRBUaRQDQuB1VG+K77UZNzdvLEX0+Buz//k4OCwrwhwPcwH3ZGTJ0 qmUUhSzYjPIViQt3PNtH2aVMwNKgxXdTDZ2m2cm8XDtpW+8MV5MjMBV0FaOAeWu9 7xjqiAnZ8mIIt1HtSCfaJaHSBgzvEI+9x8a2AV44yFKA6unQGZNrBA6o+pOF3sGF BFV1aMA3teXeZsdo0HHf6th3qxCwgQ1BAZEU2JpFcJujDmIbD4WnmjCj0yGMLgkK A/BHZqdCTGn19MYVgchDVS9iJ2AHw99Yjj0mpVwj1h7KlzJREHnv+5ri1+Bhm3e+ kfaBg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeitdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhihucfi rghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenuc ggtffrrghtthgvrhhnpeeuvedvudfhffffhfelueehvdejvefgleegteegffetudefleeh geefvdehgeelteenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 7E40C18C0067; Thu, 4 Dec 2025 11:46:48 -0500 (EST) 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: ALvh3TDXSVwZ Date: Thu, 04 Dec 2025 10:46:18 -0600 To: "php internals" Message-ID: <51e16864-0867-4593-a51d-16b8e9fb8fe2@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Nov 4, 2025, at 2:13 PM, Larry Garfield wrote: > Arnaud and I would like to present another RFC for consideration: > Context Managers. > > https://wiki.php.net/rfc/context-managers > > You'll probably note that is very similar to the recent proposal from > Tim and Seifeddine. Both proposals grew out of casual discussion > several months ago; I don't believe either team was aware that the > other was also actively working on such a proposal, so we now have two. > C'est la vie. :-) > > Naturally, Arnaud and I feel that our approach is the better one. In > particular, as Arnaud noted in an earlier reply, __destruct() is > unreliable if timing matters. It also does not allow differentiating > between a success or failure exit condition, which for many use cases > is absolutely mandatory (as shown in the examples in the context > manager RFC). > > The Context Manager proposal is a near direct port of Python's > approach, which is generally very well thought-out. However, there are > a few open questions as listed in the RFC that we are seeking feedback > on. > > Discuss. :-) More updates to Context Managers: * We have added "masking" for the context variable, using essentially the same technique as the block scope RFC. * We have added support for `try using`, as a shorthand for when you want to wrap a try-catch-finally around a using statement anyway. More details of both are in the RFC. As no one seems to have a strong opinion on `continue`, we will most likely proceed with the current approach of matching `switch` behavior. There doesn't seem to be much interest in making `using` an expression, which I find unfortunate, but that means we'll probably drop that. Fortunately it is probably possible to change in the future if the need arises (the way `throw` was changed). --Larry Garfield