Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130709 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 3B96E1A00BC for ; Wed, 29 Apr 2026 15:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1777475137; bh=SY+utlbhf6bc5dfZFyAvd5n4mdzJpTKOVxsMBaQqrV4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=RytbyGrkJ4u+HbKUUY3VgKTmzLOnjmc79eGDH/fomNFZS+r6LcihWydRoHAuTVWVx zof3ZXx85vjm7ktfTly8y028+AyiHxlBAIvEowO0YDOuRRSQ34vyHIyLDXcUC6+Bqq n2xC+HFIHj2EGjFrShJoxU5w2ktz2FTPi0bfuJNLxekPVWMKFOD5nOPztYizKUe1yE ZIRwOHnDytJLMqekewMHiu72CqgKx/SkCIgH0WS5XIylXpc70KtEK7s1KpaQ8Pb2ZX poHanLtAd2z3r5S0/Xjrb8uI+ODHMPcbsefeqjrq0hgFKp45GBJlScKyBk4N4sSdCz 9rfiWHX99ZGhw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 771CE1801C7 for ; Wed, 29 Apr 2026 15:05: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-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.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 ; Wed, 29 Apr 2026 15:05:22 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 74DD91D0024A for ; Wed, 29 Apr 2026 11:05:16 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Wed, 29 Apr 2026 11:05:16 -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=1777475116; x=1777561516; bh=ouDj1OovT63+ShKjnrfQE +/LyBCoSqhVwFVfN8lr4IQ=; b=MhUTiG0BGzmqFr52MHIhGx+UOpkSp0x4paknM pxqJc3S3COhPgvVdOeYInjRjjfhXVd8TY+Uj8XBjShKTZzAFOFJBpywrQdspF6Tw jikQ96YkPKPsy8CpgrkpjDlewv61MkocFaR1nmAQUgWB8dXJxHitT0cdQuO3mC+8 E/e4Pv+FTPazDXLtJeGnKu8v0ZlzZLjoqaceA0AgIC5TCxDRP5zm5jcOQvs8rbTK k6aGNwl/SzfeyKqhnnSJWvro+4H6HQhUUe6wgid88IjzKxxTsCg52VmXwyn6I1BR rxuw+YNl8H4sGUu9JyoWas/IQv/koqLiHmrQwudG17oOUrdfg== 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=1777475116; x=1777561516; bh=o uDj1OovT63+ShKjnrfQE+/LyBCoSqhVwFVfN8lr4IQ=; b=F8lXLf+3sFb3u4ZvY IkN3yBOrDuD0ehGAFHD1+lU9GvjIHUQnIpCNkgV9xUpcSdYXspdjm+PWxb4H7sG6 A3XAG4VvcVI2df6iOJ7944Q5xkUD7dCAz1Ym7I3JeW93l1EbRTsqU+whxM8+8VHu BMzi0QH9pW1oJ49v4SKooSWwVL9HnNCvD2YzwoTDUmI7cPNU1ggSJKv1IwWfnKT8 ghWHs6IIsgJEyKxLRwAiT65dneb0IOlAVoRVdyZt/jciYTnTBd+FbunQHzKtHwjP XHajKavfGftTdzEIUgrbtNYKHvZ63bcTJnGcZ6qeZk9FwC40Zm7asTL/kGXYNpaG Okn5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgeejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepffeiiedvhfdvgedutddtgeetieeugeevhfetheeffeeftedu iedthedtgeejueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id B787170006D; Wed, 29 Apr 2026 11:05:15 -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, 29 Apr 2026 10:04:55 -0500 To: "php internals" Message-ID: In-Reply-To: <8ab92f4f-0fce-4239-9732-2d5c7ae1159d@app.fastmail.com> 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> <8ab92f4f-0fce-4239-9732-2d5c7ae1159d@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, Apr 29, 2026, at 9:30 AM, Rob Landers wrote: > On Wed, Apr 22, 2026, at 20:28, Larry Garfield wrote: >> I think a key question to answer here is: Do we care to differentiate= between CM errors and underlying errors?=20 > > I don't think we need to differentiate at the CM level. Suppression is=20 > a policy decision that belongs to the caller, not the context manager.=20 > The CM's job is cleanup: rollback the transaction, close the file,=20 > release the lock, etc. Whether the exception continues propagating=20 > after that is the caller's call, and `try using` already provides=20 > exactly that: > > try using ($db->transaction() =3D> $conn) { > $conn->execute('INSERT INTO orders ...'); > } catch (ValidationException $e) { > // Caller chooses to suppress this here > } > > That makes `exitContext()` simple: return void, do your cleanup, and=20 > get out. If cleanup fails, it throws naturally, and the desugared form=20 > can chain the original exception as `$previous` so the root cause isn'= t=20 > lost. If the caller wants to suppress or differentiate, they already=20 > have `try using` for exactly that. > > It's worth noting that every example in the RFC (database transactions= ,=20 > file locks, error handler swaps, async scopes) does cleanup and=20 > propagates. None of them actually need the power to suppress. If a=20 > context manager wants to give callers a clean exception hierarchy to=20 > catch against, it can wrap underlying exceptions in their own types=20 > during cleanup. That's just normal exception design, no special syntax=20 > required. > > =E2=80=94 Rob Just to make sure I'm following you, you're arguing that a CM should not= have any way at all to suppress an exception? I don't think I'd agree = with that, personally. Even if it's a rare case, I do believe it's a fe= ature that should remain. --Larry Garfield