Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129460 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 6D0E81A00BC for ; Wed, 26 Nov 2025 17:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764179344; bh=ZFsYF4L5J3zWZMxgErIATU/OkGkiLKBCTIZ37CMMQH8=; h=Date:From:To:In-Reply-To:References:Subject:From; b=miU+L9bPL61AVgBbil6DYzoRC1Yfm2JnSM3uocgjWSgeMnbXrBbtL+CAM0D2k9Dqb Qk3aCdqIdya3IfTdYpbTAWrGFbVZf7SLTGVgsEeRjlT5Nuf78DO1t+4/lmqgjcKxOp aQhHiyNJVQxjRwcV02tiDyfuCqGJ46jlRALNFZNrQoQ/r8ODYOWyGd5NAou4x7CW7E 635M5zSZLIh0EDYfqVJ7SFv06gUNfsdbjsGgyquoSreTZ7H9UChLf4xxd0ERnUuSqW moheLbixYxp67rKW+mJc3C2MIpamBs4Q1bzinu191bGtxCruNigI46bU80jWJ66ign GPReNPzzmT8AA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 00E39180082 for ; Wed, 26 Nov 2025 17:49:04 +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 fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (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, 26 Nov 2025 17:48:53 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 38A7614001FF for ; Wed, 26 Nov 2025 12:48:48 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Wed, 26 Nov 2025 12:48:48 -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=fm3; t=1764179328; x=1764265728; bh=U4UYjw7iq9sRieM0B6wuH CMAEquE4HN7MVodTSryin4=; b=C2by5eJ2l3I+INWPuR42HCVTqbrWdSNBGaQFt vSXHjk4K/IKXzqUtwaFcpQVSyHtKAWVoXUY/kvlgWq/4SqkNQZMzaNqiACf3yVEY 0CFk+nN/sZHtvV9xwEbkp7iCX1jAM0IDOFoxU298mxCgmtpYIxtQoIYPevPMJbn7 8p8+USdZ6+q/TOsnUgiqgnmCejhYM+sAC3J8JtjP0+caH4iSQ3jCHA4vGCglrvBD ttBo6R9QRaczvyyx7EX2k3yy+QuBB/Sme+0dHA46PsRAxtb0OGACCl9VnD0TC9ta IkLmNhk48eSGQYOL73Byta+LxSstwrpv3FMKou1sfzLeAENTg== 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=fm3; t=1764179328; x=1764265728; bh=U 4UYjw7iq9sRieM0B6wuHCMAEquE4HN7MVodTSryin4=; b=E55WlVb5BO/glddZY y5QvwjE6GVkZ3O9SmS2yRz12vbSdF8eubxcNZ7hVA/9ES7oTKobH3tuvDAj/RPmi ghE6ot35ktY15Gp8LF4U+ErDYdIB0DShC19KqMBIjiRreUs7kA8QK4cqd7sDoE66 PS72ePD5ISYjO93sXpCVph0nbzf0xYavuhT+8VOx9b1Zxcu3Z4asEgIW2TyOAA6z 7mO0nYahLjqQw8Ro9zOL7AN2PELH8UEfdvFHItLPSWDEV/O4bcySwBnmayHhPMDJ c5RjIc+xfT61nfrEK+Z5ACqGgrk+55TC9ZC1urFktJ6nhgaG9dsfWMEGlhEu+2TA Ltb+Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgeegleekucetufdoteggodetrf 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 8695318C004E; Wed, 26 Nov 2025 12:48:47 -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: Wed, 26 Nov 2025 11:48:27 -0600 To: "php internals" Message-ID: <5c6a17a8-e3af-4c9a-90bb-3e4a471e4a49@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. :-) > > -- > Larry Garfield > larry@garfieldtech.com I didn't mention this explicitly, so I'll do that now: * We have changed the keyword from `with` to `using`, to avoid conflicting with existing global functions in Laravel. * As requested, we've added support for multiple context managers in a single block. They simply transpile to nested try-catch-finally blocks. There's still 2 outstanding questions: * Is there any interest in turning `using` into an expression rather than a statement, so that it can be used in expression contexts? * Does anyone want to argue about how `continue` should behave? Right now it matches `switch`, for better or worse. We're happy going with whatever the consensus is. If there's no feedback or consensus, we'll go with the current implementation. To me, Rowan's experimentation really shows the value of splitting the manager variable from the context variable. The amount of flexibility gained is dramatic, and it makes many implementations much easier. --Larry Garfield