Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130647 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 B40091A00BC for ; Wed, 15 Apr 2026 18:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776277653; bh=xm7PWUUdQvDdtK0L8CkuE1QVlmbvINN31dVwkByQhWM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=ZpCfxYSatmVq16YzzeWyPU5bY1/QSn8FeUdjSynvywt3iCDhTNhQ6y3P1IVMwoif4 VydeHzpMkyDq0bq/t82Pb6/sJHMwwvgWj5Uy71TaT9vu4XA+2QjeGluBGzrI0hVL/c jrI+0zbkchOh/GVVknMrWisZ4YMlhjhnMlVSYeOXGLEndVPWGQYSlMTL/C1LMVB1Gy dB3x5WrelJSASxTM+Mel0rVc2625dzi+sY+yLqSrJoFA1+8BUgjPS+15uRhNdhwaGQ mN0Cty8JWUPAlO8V+kKK1lqf6he2kuZjPd2eb+g/hHkbu/blhLe8VZRBZqaqfTKfJf Jt2HVSsPeNGqw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E77D180032 for ; Wed, 15 Apr 2026 18:27:32 +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-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.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, 15 Apr 2026 18:27:32 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 93F9EEC0219 for ; Wed, 15 Apr 2026 14:27:26 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Wed, 15 Apr 2026 14:27:26 -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=fm2; t=1776277646; x=1776364046; bh=mjiWv/GGmvsEP+FjdK5t6 HDN6/mnXFV182qkmVPuIiQ=; b=InPOM/BwkAahUouiWGluBkOGMCsfMxkIULYLo frDn4XmJhdJo81wt9IZk0xWcOSS6bOJeKjxYYz9VdzMMbhmhRQ/AG4EQWyYJFaSV wU9yxBmopMOVwjdsH0BSJUYAwxCGOw795lbx7gUCRiueGtdpGl2l4NEx6CGvYZqR nCpJ8iHHn1bUlzb4FlkqB4H8ZCCNx/Yuqh/fuOcCduHhtHlAo6DTEBDmD49t/5YM ZS3LEiYIDRzjuzOsAKNR7cizsEAbgeB4bRpr4l6Lrbv787bou5WHeKI2eY6JZsRC hI9gpn9rCvQhgPQldjv7/trf9pr9tUNyKDuAsEpsdfoLvLNsg== 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=1776277646; x=1776364046; bh=m jiWv/GGmvsEP+FjdK5t6HDN6/mnXFV182qkmVPuIiQ=; b=bmiudaVnnubSE6p34 PRwE9/GUWc2o+wtyT6IEJkRw+Xay2e2RBoCSFPVHmeNe+ZzCTJ/wE4HwmyPcFsNq k7+90CiDkETtD1G6pVow3n9PYvh+iu+DjzJIi4yhRUSGHp0P05tPrlashLn2JiIL mIfFBYMOpr1EW30Kz9g7zPrP6TSbw/Nwy1WtPpkcIlumT7Kgvju/vIeX0597ZqLn GVTgHDDO9LaODycfZaFIb+TpdxBFqmKOS5rbcDbYNLO81igumnbo3W+gUDMF197T XXFTmaDLPdcGCwvGQ0oVDjIj9xWirwf/QyMSfThpDzpd4Q1xQ9ELF/V4kMvu5Wis PzvuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeggeekudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepudegvdelgfeugeehfeejteffudevleethfefgeejffffleeg tddtveekgeekudfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 48C2A700065; Wed, 15 Apr 2026 14:27:26 -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, 15 Apr 2026 13:27:06 -0500 To: "php internals" Message-ID: In-Reply-To: References: <5d96fca3ca5418e6e9e5d8871b26477f@bastelstu.be> <7991abf6-9cc8-444e-885c-4f8cd6078fa8@gmail.com> Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Apr 15, 2026, at 11:39 AM, Alex Rock wrote: > I have read a few of the messages on externals.io, maybe not > everything, but your answer indeed makes things a bit clearer. It > mostly makes me think that this RFC is a bit complex and I don't see > *many* userland use-cases that would actually need this. The RFC lists several. It's also all over Python code and has been for years. Though to be sure, people writing `using` blocks will outnumber those writing custom context managers 100:1, I imagine. That's fine. > IMO, it tries to *make some safeguards* implicit, like closing > resources. I recognize that it's useful for this case, but does PHP > really need a new feature this big "just" to close resources 10 > milliseconds earlier in a process that takes 100ms anyway? The benefits > would only go to projects with huge amount of concurrent calls, which > are not all of them. "Big" seems like a fairly subjective word to use here. It's just an interface and some desugaring. Compared to many of the changes already added just in this release, this is a small impact RFC. :-) And we know it's overhead: It's a couple of instructions that you would have written manually anyway, plus 2 method calls, which you may have had anyway. So, negligible in practice. > No auto-capture in closures is IMO an actual *good* thing, because it > avoids having issues with the current world of JS/TS where auto-capture > is default, and it brings problems with references. Almost every language has closures with capture now. Only two require explicitly listing values to capture: PHP and C++. Everyone else figured out how to do it safely. The problem with JS is that it's by ref capture. But that's off topic, as we're discussing a feature that doesn't impact closures at all. If you want to make a separate proposal that leverages closures, you're welcome to do so, but that's not what this RFC is about. --Larry Garfield