Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130631 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 AFC8A1A00BC for ; Tue, 14 Apr 2026 14:18:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776176319; bh=gatyJKZpkmOYqWGabxcH9blExomobfA6UdptDOXbm7g=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Y/HxA6hvZsld/nESBCXreB2rrVk2t/46zo4DSrJ0wk1FR2J7bfy1Hx4txpiq2IM0L G3TdYULVOZwqHFFyidzvwS50lyapRcuilvZwUI8cHgU22Ysuim6WnnT2WgWaVg4mn6 ws5xzaiRjFs2cuond0Wrfc6oIFZSDRAL1DUW+RO1DOjIXE3nKw3F/l3eefKddGdbKb TybXHTlBHEJB0lmisb0EDcO9u3jLoPZSCF3dQZLDi9kyvv7LDQVt1CaWObfT4S0oVr gttFcZMx316G/CK/UOfCDvVSYy6pgN8zzfbpHzBIdfUrtWQXS3VQYa79dFoGK+LaiT ldRbOsSDtDkbg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2297D18005D for ; Tue, 14 Apr 2026 14:18:38 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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, 14 Apr 2026 14:18:37 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 79F8B7A02B8 for ; Tue, 14 Apr 2026 10:18:32 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Tue, 14 Apr 2026 10:18:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm3; t=1776176312; x=1776262712; bh=YPpmUqKyKu powk/td/vIzxgEJbabm03y39BzpLUzJvs=; b=Ia2TyyktHCH4jsr95Qpchfy0Gm 79aRgdOb5julbmLTzOi8josbv65RztqklgDOtOkkT+eWV/hS1BAwlHp12jqP3sdc J5930nXddJ5kLtUYh03ms7IqorMVJRkcCePn6QFHKJgqwssBye+VVA5p4C4s1ulg pPtYai//qr4AO1eXFWPCKMIl992/g+FyRnt61Pbc0V66o/UDLsOOCKvzHp9OlUr3 RwlSykRH7L8JZ7D3GzN93qI3BiF0YDK5V/07dTx5zY2UCuc34bp6hB9rhWdfrBa/ ce9iQF6s0nHYD/zy+VP2KF4u2lJWGK8P3fRKyX6tlcICW1Mh0W5gg78H+aGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= 1776176312; x=1776262712; bh=YPpmUqKyKupowk/td/vIzxgEJbabm03y39B zpLUzJvs=; b=FirOLg0Lr9tPHp0ItSXVtNycxdg5g24AHQsrmWJ9XUfOBrQdLUw 1Yro4X1ZaNs+4sz+kZlz8TGhu8xvtY+X4LTXo7ItXXdCR1mqOpKJyaKHwa1HNePQ 3iGnsBhXFZzbrsq8A2ShufFA//tyqCxnmxbxHdvGqkFJPIpH6u5vrQz+ay7uzG8r bGoEp2nMOKoN2JnoFYU77Z9MBjv/YH+HWqRbPJzFnBBPhFFCs8Llmwg+HUeQkTAw rweW7PyK3vXfPbgbpfDVADzGDBIKKmcZgg4FgiduGQvh/QRUmWBvJCya3d8L+2hy fu+w3m27jDI0iKRg/TZJO3TsaNmHRCSkUEw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdegudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertd ejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdr tghouggvsheqnecuggftrfgrthhtvghrnhepleekhedtgfefhfelieelgfegiefhkedvle efjedtffelhfehheffgfduteduuddtnecuffhomhgrihhnpehphhhprdhnvghtnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghoth htlhgvugdrtghouggvshdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D5444182007A; Tue, 14 Apr 2026 10:18:31 -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: AJqZv0gpVmjF Date: Tue, 14 Apr 2026 16:18:11 +0200 To: internals@lists.php.net Message-ID: <4985896b-c80a-4302-912e-9f572a260fb5@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: multipart/alternative; boundary=9558b9f8b29f8f0508ae6b289e02ef6115312687 From: rob@bottled.codes ("Rob Landers") --9558b9f8b29f8f0508ae6b289e02ef6115312687 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Nov 4, 2025, at 21:13, Larry Garfield wrote: > Arnaud and I would like to present another RFC for consideration: Cont= ext Managers. >=20 > https://wiki.php.net/rfc/context-managers >=20 > You'll probably note that is very similar to the recent proposal from = Tim and Seifeddine. Both proposals grew out of casual discussion severa= l months ago; I don't believe either team was aware that the other was a= lso actively working on such a proposal, so we now have two. C'est la v= ie. :-) >=20 > Naturally, Arnaud and I feel that our approach is the better one. In = particular, as Arnaud noted in an earlier reply, __destruct() is unrelia= ble if timing matters. It also does not allow differentiating between a= success or failure exit condition, which for many use cases is absolute= ly mandatory (as shown in the examples in the context manager RFC). >=20 > The Context Manager proposal is a near direct port of Python's approac= h, which is generally very well thought-out. However, there are a few o= pen questions as listed in the RFC that we are seeking feedback on. >=20 > Discuss. :-) >=20 > --=20 > Larry Garfield > larry@garfieldtech.com >=20 Hi Larry/Arnaud, This is a pretty exciting thread and fascinating proposal. That being sa= id, I have a couple of subtle questions that don't seem to be answered i= n the (very long) thread or the RFC itself -- If I missed it, please let= me know: 1. What happens if a Fiber is suspended in the using block and never r= esumed? When is the using block released to clean up the context? 2. There's still no mention of how this should affect debugging, will w= e see the "desugared" or "sugared" version? Is that even a concern for t= he RFC? 3. I will say it is weird to have exitContext return an exception; but = what happens if an exception is thrown during exitContext? Why not just = have it return void and throw if you need to throw instead of having two= paths to the same thing? 4. Looking at the desugared form ... I'm a bit confused: if exitContext= is called during the finally path and returns an exception, it is just = swallowed? But if it is thrown, it won't be? 5. That being said, I don't think the RFC shares with us when we should= return an exception vs. throw an exception. =E2=80=94 Rob --9558b9f8b29f8f0508ae6b289e02ef6115312687 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Tue, Nov 4, 2025, at 21:13, Larry Garfield wrote:
Arnaud and I wou= ld like to present another RFC for consideration: 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 s= everal 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 note= d in an earlier reply, __destruct() is unreliable if timing matters.&nbs= p; It also does not allow differentiating between a success or failure e= xit condition, which for many use cases is absolutely mandatory (as show= n 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 fe= w open questions as listed in the RFC that we are seeking feedback on.

Discuss. :-)

-- 
  Larry Garfield


Hi Larry/Arnaud,

This is a pretty exciting = thread and fascinating proposal. That being said, I have a couple of sub= tle questions that don't seem to be answered in the (very long) thread o= r the RFC itself -- If I missed it, please let me know:
=
  1.  What happens if a Fiber is suspended in the using block an= d never resumed? When is the using block released to clean up the contex= t?
  2. There's still no mention of how this should affect debugging,= will we see the "desugared" or "sugared" version? Is that even a concer= n for the RFC?
  3. I will say it is weird to have exitContext return= an exception; but what happens if an exception is thrown during exitCon= text? Why not just have it return void and throw if you need to throw in= stead of having two paths to the same thing?
  4. Looking at the desu= gared form ... I'm a bit confused: if exitContext is called during the f= inally path and returns an exception, it is just swallowed? But if it is= thrown, it won't be?
  5. That being said, I don't think the RFC sha= res with us when we should return an exception vs. throw an exception.

=E2=80=94 Rob
<= /body> --9558b9f8b29f8f0508ae6b289e02ef6115312687--