Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129754 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 A7C581A00BC for ; Tue, 13 Jan 2026 22:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1768342813; bh=ArYEyKa5A0InxYpUsKO3jv7OR3DeUoxNrX98kvVlhkE=; h=Date:From:To:In-Reply-To:References:Subject:From; b=R6CNf2YT5P/bTygtCWVFWZggvX/qTCcXQQ3qquladqKfq8WWvZc/0jX7Q2g++lXSX dBlC3EC8Z85kuzbJ0hTyQsu+p77pWf6kFlDunxEoyBn9mW1qQP3RizPp/cD2lyt5Zw JwDHQavEH6Q/WDzI+nnZhhpZjI5R2NoAz00vUCU47V7Ms0O4ArNGkTnuK7Yn3+f8/j BQP9xYkxu2lDbQhiEmWW+U9qaU/am3rhg05ysz6iVhshih2k289eigGjgESSRGhgxy j1kFzThgvyqtvV8KKtw7epK0VEWbhv5D6oUYdHlxJTs63FinmpQM5f1uHLoOGHvZEI qbjWNrMWHLSWQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 359901801E3 for ; Tue, 13 Jan 2026 22:20: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-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 ; Tue, 13 Jan 2026 22:20:11 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 20CEDEC025C for ; Tue, 13 Jan 2026 17:20:06 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Tue, 13 Jan 2026 17:20: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=fm2; t=1768342806; x=1768429206; bh=wlmRSCgrgRqxPOVmfJoOj KiXQDc29B1lUtVxufe78xc=; b=pW1po8C18BaGLfcK672uK+hhLa49KclSCQFTe 7eonDa4pAxnVqLbqOxvIXfn+dhUqaQiqTjNzFaBkqnR6gMT/NI55G8v+MIQIV2of YmuUwii5hSvHr6pWty1cGeytxyyKoP67/YLHCKXfihegAxgE+i21SsTWfkyG45Cn 9ek9zwLxQbHetBnoFNiIOfamboU6a2wboGiKEMTiDDPqMzEILfS6RIrekz2lCXDL X0bqfM9nYDRVP30grzl0PtF/dZutRPvRZc4ZJy5h5sSvRb1l66mtZkj3NjpoI4el PDJK0DsXXzhrBUUOycWu8KLGKCszcpGGTj0kva/xA/E1QrAUA== 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=fm2; t=1768342806; x=1768429206; bh=w lmRSCgrgRqxPOVmfJoOjKiXQDc29B1lUtVxufe78xc=; b=mAmphzLYJS2RwJfcp V7rDG/RQkxLfXoGuF2RAN0k9VDgSgrBGtuLlharNfuLyLCrk9KcX3rArdSyJt3/v E1SZbOQ5Q7/BSLZ0uCB6wBVBYD0pzOSkqoPh+g3TY+rHYry/DG6e+30EM52PrvH8 xi0m2+qyqy920iIgM6hXDtwGB5Z7LXoGB1QleuGkpmlQJb6A1kqty5kCtNNxjw9B MYBK61RZ7zuHKawRjwWDP8ZkoqeQo7cmYFbZKXMB+/+oK4Dr1rztdGFpadOQGeJ2 VYABoHSGeokbwLwfhoKAbomymArmfq1N+QJelQrc8Gg1HhHnBzgUg15jqmmJeA8O Ds1nQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduvdduhedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeeuvedvudfhffffhfelueehvdejvefgleegteegffetudef leehgeefvdehgeelteenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id A518670006A; Tue, 13 Jan 2026 17:20: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: Tue, 13 Jan 2026 16:19:45 -0600 To: "php internals" Message-ID: <905d9879-70ef-4c87-8578-26519c6d4818@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. :-) Hi folks. The holidays are over, so we're back on Context Managers. There are three questions outstanding, 2 of which we want feedback on before we can finalize for a vote. 1. Discussing between us, Arnaud and I aren't confident in expression-based `using`. It would necessitate a trailing semicolon in all cases, and while we have ideas for the return value there's nothing that has clear and indisputable benefit. So we're going to drop this one unless anyone wants to make a strong case for it. 2. The syntax bikeshed. Right now, what we have in the RFC is `using (new CM() => $var)`. We feel that's sufficiently self-descriptive for "produces". However, there was some pushback on that and we're still open to other ideas here. The critera would be "clear, unambiguous, and easy to type". If there's no clear consensus, we'll probably stick with `=>`. 3. One idea we've discussed internally is allowing non-context-manager objects in the `using` statement. If the left-side value in `using` is a non-CM, then it will itself be used as the context variable. It would still get unset at the end of the block, so if simply unsetting it is sufficient cleanup it would eliminate the need for a wrapper. This would remove the need for special casing of `resource` variables, and would also, in effect, absorb the behavior of the block scoping `let` proposal. The block scoping behavior becomes a degenerate case of `using`, feeding two birds with one bird feeder. (To be more animal friendly.) I'm open to that idea, though Arnaud doesn't like it on the grounds that it could be too confusing for folks. So we're putting it out to see if there is a consensus on it. Once those issues are addressed, I think we're nearly able to take CMs to a vote. (If anyone else wants to weigh in on some other part as well, even if it's just a voice of support/approval, now is the time.) Cheers. --Larry Garfield