Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129077 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 0632D1A00BC for ; Tue, 4 Nov 2025 20:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762287358; bh=T8KTkuAstYQReZ99F5FtM5XJia0MQf9Eg7FAbPgV5+A=; h=Date:From:To:Subject:From; b=L3WdQUPj1VYSb9Sq+x22/sAtXyR7RmKcEmW6ktxhdBALAhYabv2YQbwND/y12H0Zy ekuM9GVemCE7lsx+aRq57TdzXIP5z6sy3a+0Q5Igz+UftwM/qPlJdcQSkkSswXBqC+ EWTsFG2LuNPQkEvDZOrUENlNjgjgYmW+gyprjsPlPCnSOeXlO3jhcJ5CW8KDIFlKpx 8Eor/osFqBAHRDzhsWdxybbvNNIM6N8cxqzC1pA8rTy+exHMtx9W0HCVbDd86T6Vrb pwPfVkiWsogEqprURcwkiCc/J8n7hys7TsHmvPUOa05FFkX6T+mJYttdT4Oj/H52OF VQn+95NsidkjQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BBF7C180077 for ; Tue, 4 Nov 2025 20:15:57 +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.9 required=5.0 tests=BAYES_40,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-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (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, 4 Nov 2025 20:15:57 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id EB1C2EC00F3 for ; Tue, 4 Nov 2025 15:15:51 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Tue, 04 Nov 2025 15:15:51 -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:message-id :mime-version:reply-to:subject:subject:to:to; s=fm3; t= 1762287351; x=1762373751; bh=rDq43qXMffHbjHO798EcivPj//Algy18JKS EA6QvCm8=; b=R5G+J5vbehlgL3onPu7ziSwnebJ9Ea5s6pA3C5GEithx4FZ7Zpi RL6/rqw3MaZLS5idgVX3e35oUPgKtwlmLZVgcbSaYCDG8gu4b2uLq0NrxPs64OHx PH2waVmUVXWCctnOzDJKFj/dONe4GlxXK0VxI6YD9ozVscPqstBCMb0BaLP0CHLT qHE32r2V9E9vh/nftPF8/oVlTMy1azYVdt/z2DibCdGnX7k1xF/SrP8nXwsn1MG+ Y3q5E9U7rMBu0OQmjWx44Xanrj+BJOKq4OF6v+YgXHXtBGNtK7a95OO0sn0jCijG 1EBO+ij6EfeY8lSNvBJQAsvdsnDXaoSDwsQ== 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:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1762287351; x=1762373751; bh=rDq43qXMffHbjHO798EcivPj//Algy18JKS EA6QvCm8=; b=vnAQUN728mHZGYn7rm9FyC2Dc2h1FfVVV+ind9wlJNRl18y6V4v aUTG1YWYJqCVwh1s+E1VbrcUOeQf41zdsynwMkP7BE68Irz52wA580JhBfCLcjCp jJjFg+bfvQWOFXGOPPwFidd2vEIAGqwffi68SHz4eZFPSrJ+6Y7ZeSsp+sJ2Jt94 aBWv4B52K+jLWQLd/8x5vAF6UeLrNb1s1YXajQsc7JWVxIxh7QAQ5IBDczPwsV9T IHDKQo7X1zHjYBUAgD2hBryOvg7S6xisJfERF0ryNWFRxc4Tgp36/60WS/aE37cB minPaJ3k+R/nipR/K6pXd1QeMBO8y32rXOg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddukeduleeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhihucfi rghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenuc ggtffrrghtthgvrhhnpeduhfffheffkeeivdegveehleejvdefffejvdfhueeuuddtleej fefgheethefghfenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8F38C700054; Tue, 4 Nov 2025 15:15:51 -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 Date: Tue, 04 Nov 2025 14:13:18 -0600 To: "php internals" Message-ID: Subject: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") 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