Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129080 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 8DDB11A00BC for ; Wed, 5 Nov 2025 06:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762324189; bh=1zC97VspYV9q+Ekd/G81U/splhYRYjKxuqO4SuEoIcs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hXX8r9EJS7uMoGDq7GCjSJA4Vg4dklYOVpQglYzcm6by/3SMMmc+BkoyHmSoCAfLT ZpQEYdiSoxalLApEyRogOI9CaA2VxhqwW6EjHSyrwjg5/17i1ZwGiAXg7G1Y7s6FcG 97IvLQ53AC9Vn/wQ2ijY3num1Wtgqro2jRmObY0YPxsKgv+7vlTH94pT+BbJhYinef 7C2Ur0v2PG3orCyYVZt9w45dpSppfvH50Zqcb3WH3oL8vWIhgk+T9BRzkKkN+C7RQT 9+FpZXuNEO+xFSiNalmw2fDOs7y+a2GnEgs3/ufn0acM9fZZdOqPs4ZO0JEo0bXIir udrMJz2tSRnaQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7AC5D180082 for ; Wed, 5 Nov 2025 06:29:48 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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, 5 Nov 2025 06:29:45 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-3717780ea70so69963441fa.1 for ; Tue, 04 Nov 2025 22:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762324179; x=1762928979; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TwQFii2dcqwgE8zrDGu+ega3+fkcMjV1FU7U1kMSUn8=; b=NT6iOUFy/UVRK0eQIO8Fq7EGUNIcq7RGyuDW+7TQqyxALHl+OwSz8xoa0pwcUl7h+M ux3tjEN++m+ai1loySFSUMab5eO/0J96atwJKNJmeMZdZGDFryb0Tc+9o4z78PsyvK50 3fxkqgRzhiik3rAF9KbyprOeCCxOXhXae6BrWmEHJfQtb0oZreeMM0/21hqJBW9cIvnJ my5vUNgBiZlCvg6EKIsOqo5d4DnAwu/DA9ejg1EBkrvSLPMKv3LK+cAKtmyB+62xgNPA KjhwcBKaYfrvtWYkMdiA/Ax2XI7ueJfldHExpJuIFwI89lM1Z2K166ZaJzdfBbKUhuWb VmpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762324179; x=1762928979; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TwQFii2dcqwgE8zrDGu+ega3+fkcMjV1FU7U1kMSUn8=; b=dD2lOTSenSF9KT0i8eJZysXe+mRR9rLTORiDCXXtv8axkfbqJR0bHcAZJW5ZrFrP5P 3Q2Vf+dl+DT+najlcQWSxvCEc/zkabvV+2aU4zjCokGviJeCg/2pTNX4N2XXN2U2oSRu b7SQgSrlP2HJASBWmP2MrBkvnCsyYlV6HEU3Gw8pcUMfHm7VQX5q0mZKiT0p8B2QBuEX xR37b0I5Y8YukRp9MtwPsq31Pzu6y3lnpED2jLtdgZmfT4C/SdaaDIfO9n9LEoFIr9xE MEQYsA36H0h2Ykfu5L4d2oXeSl4xhB5LVvjI8tnGi5pzHW2QuCttGY33cOYiRhJbYUgA mVkA== X-Gm-Message-State: AOJu0YzyXMc8V7ObbN/sGnbY9g4KsIPSqJdoshIacjF6w6w7nQ5tv7Bj z3oXpYGNorbt8UuWn37Aur4RnR/cliUI7Th1Ms0SD9Q8eo8J2nDapneFlK/xzkI9y67T6ST8zlw giVGEK3rz7ueJCDl2oOqziehJFG6vZSJPjQ== X-Gm-Gg: ASbGnct27TxZorBDTKp6JnLAi+xi80pg9ubkeErXQBfnQ5tBGmoo3NeQVmmR7zZ+oSj n6iiDvu8E4Ct5LOQR1JwSmTzy7+dyEYFi5v35sHfgx2Qlnxzp7v8OEixia5baWvi08vdjxgsc2u ndeD79zBO5G3mSf7+Z7r6KCGPJD/VA3OoqHLTu+TqlzciJQ/kthlo/UcyfjcdxU3C/A2nBHOZlG Oa3MMwFUu/J4JSJu5QdbgGdwRbnGIZADwixVDA3wIjIprkMrKfFC0/jwAi0S+7LGacCrWe1CqNU Ma6yvA== X-Google-Smtp-Source: AGHT+IFu4To2ApBTR1B2mNpUqQbFI7Qpi1wd8M0YrODtPs5eCrnyEownVrAIFlee2LTClLM4TRLOaFKEoy5fEZ5KwV4= X-Received: by 2002:a2e:884e:0:b0:37a:4732:91d3 with SMTP id 38308e7fff4ca-37a514a0785mr3791281fa.45.1762324178163; Tue, 04 Nov 2025 22:29:38 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 5 Nov 2025 06:29:29 +0000 X-Gm-Features: AWmQ_bnNWxGusfXI6-uN7rVqvYt0bASmiBFG710DyoYweD2WOsM8BuM4M4H5pAw Message-ID: Subject: Re: [PHP-DEV] [RFC] Context Managers To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000009e5e330642d312f1" From: dragoonis@gmail.com (Paul Dragoonis) --0000000000009e5e330642d312f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 4, 2025, 8:18=E2=80=AFPM 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 unreliab= le > 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. :-) > Great idea, I'm definitely behind this. I've also read through all the PR code. I have a few questions 1. Apart from wrapping zend_resource into ResourceContext, has there been discussions or ideas to wrap other things ? 2. Are there any scenarios where using with() is a bad idea or has "side effects"? 3. In the implementation code there is a lot of mention of "list" and zend_list .. why? Maybe the answer is obvious but I can't see, at first glance, why we are implementing list under the hood. Thanks, and great work to both of you! > -- > Larry Garfield > larry@garfieldtech.com > --0000000000009e5e330642d312f1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Nov 4, 2025, 8:18=E2=80= =AFPM Larry Garfield <larry@ga= rfieldtech.com> wrote:
Arnau= d and I would like to present another RFC for consideration: Context Manage= rs.

https://wiki.php.net/rfc/context-managers
You'll probably note that is very similar to the recent proposal from T= im and Seifeddine.=C2=A0 Both proposals grew out of casual discussion sever= al 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.=C2=A0 C'= est la vie. :-)

Naturally, Arnaud and I feel that our approach is the better one.=C2=A0 In = particular, as Arnaud noted in an earlier reply, __destruct() is unreliable= if timing matters.=C2=A0 It also does not allow differentiating between a = success or failure exit condition, which for many use cases is absolutely m= andatory (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.=C2=A0 However, there are a few = open questions as listed in the RFC that we are seeking feedback on.

Discuss. :-)

Great idea, I'm definitely behind this.=C2=A0

I've also read through all the PR= code.=C2=A0

I have a fe= w questions

1. Apart fro= m wrapping zend_resource into ResourceContext, has there been discussions o= r ideas to wrap other things ?

2. Are there any scenarios where using with() is a bad idea or has &= quot;side effects"?

3. In the implementation code there is a lot of mention of "list"= ; and zend_list .. why? Maybe the answer is obvious but I can't see, at= first glance, why we are implementing list under the hood.=C2=A0

Thanks, and great work to both of= you!=C2=A0



--
=C2=A0 Larry Garfield
=C2=A0 larry@garfieldtech.com
--0000000000009e5e330642d312f1--