Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129608 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 91A231A00BC for ; Mon, 15 Dec 2025 21:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765833493; bh=oRPNccU5ekGlRWpQXWztCE541UPMSg+A4gNl0P4+8u4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=dMYILWoc2sm61e5iW401c0qNTwPnNaahqcibbwU9Di4wn3szNaOznOcGqJTm3PYyC 9iSju/295wNRFe62ymycaGLx3D/sYhHiTElFalddfPaRd916ILsimEvI1aYaRcX1t1 R1iw1YCGnaqONNO0rAr4gD/WEdxcMH2HAenqD5YL8Qc2rndEoICflG7/VtU4OMzTxB d/kRLb+pK3OsQJmN+I4zqDJzwBlBqVdiAtUzZsigz4LdA6i06/3jsa/CbwbNonjmp8 adFPbIHI/lm10jz+AOPA3Fn31ZskRwPjDT5ae0X18j3SxY76+pJgAdmD4uwiM8S6PU W6atGS5AEQo7g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 21A2218007E for ; Mon, 15 Dec 2025 21:18:12 +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 ; Mon, 15 Dec 2025 21:18:11 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 4EDAB1D000CD for ; Mon, 15 Dec 2025 16:18:06 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Mon, 15 Dec 2025 16:18:06 -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=1765833486; x=1765919886; bh=REJUGhJpSWnwObRln94NE j6wMO6KZoJAK8zffH4YgAA=; b=BhqV9RtAVBgVOzcumymK663vU9ZEWcfxJtMmQ w24iq0YewDe1M9Tko6Buxy/6/cxVS+acORxywFYRAy4NaAu5GGxwrCpKq/DwFE1j 4k6mJe5ZrypHcvoUKrERbrhcUMkiB+hg8jFXz9kG4KB36OJdQnM9/bh33nqJ3tDU WNevycSj12r30sE3DqYDukEmyCnrcNZsf7VST9borak8ncgWJ8k2XUBU74W7pNZY fTenxHyyjvbzqf3LPgo4ydpnxa8cwFTHum2K857gqwMTvba+qvjN/MkkUUDGfusb 6XJKpgWQKPEcgkLb8Fn2dOUnwPBd0dpsZ7FcdN5j5MedEY3hQ== 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=1765833486; x=1765919886; bh=R EJUGhJpSWnwObRln94NEj6wMO6KZoJAK8zffH4YgAA=; b=ob7G1eaVpHXu34rNu NCsFJh8BXk+HYWYNUu/NeoXCYFpFVWEsi/+ZgO2092E1ECHtlWrlf63v0A39Kjqe RMHE/hEdQkmt1sSf99zpjeFbPxgpjyJ+IwT/aOvGTVzbBte69SIdNvbiZwJxFp5w ExmzuVtCG6cAsduqCYjE/jYufYH3xqz8ecbjz7mlZQOYNdg4DU3aouF13SSQLA8b tD0CU/xGjKYgXlD73haIhp+CoY4X0zHN4adF6tCrqOcY2Xfnl7br9ddy0WWITHbS XGIay3s3yabumr2gzlmZf55axtw8eknXHzvx2riPb56Hsd4BvW1b5yMaDfAnZ3/q 5ynlg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefjeekjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepueevvdduhffffffhleeuhedvjeevgfelgeetgefftedufeel heegfedvheegleetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhgu thgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E524A18C004E; Mon, 15 Dec 2025 16:18:05 -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: Mon, 15 Dec 2025 15:17:44 -0600 To: "php internals" Message-ID: In-Reply-To: <51e16864-0867-4593-a51d-16b8e9fb8fe2@app.fastmail.com> References: <51e16864-0867-4593-a51d-16b8e9fb8fe2@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Thu, Dec 4, 2025, at 10:46 AM, Larry Garfield wrote: > 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 Since the only feedback on what to use for "as" was that => makes sense, we have changed the RFC to use => instead. So the new syntax is using (new CM() => $cVar) { // Do stuff here. } --Larry Garfield