Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129612 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 0437D1A00BC for ; Tue, 16 Dec 2025 04:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765858131; bh=NQfUFzwv/hhD6ypbTeEgcegSTonGgQuOEQgK+TKn5GI=; h=From:Subject:Date:References:To:In-Reply-To:From; b=dxN/5XnIakcv2DU1LpGWJoVGJe8VznK7AyQrCjF9wpy7n6GnzgTLWWimMGnZZNVwG qgb6aSd8z7RkMcxyh/h9PdpuvIXgwGHcarjJGEC56lL4wTYE5z/dYdznY3YIZkOyi4 7YwHOupcJeczN5ltSDYsDC2ZfqGUijXWkuC8d1KsG2FrAVKBtij35pf4wzwB9oKEZy lO0zY2gIzPsnc+yVIveAy4Ai0WbcGG+w9FGcV0o5ch6xfuj1pNb7+bfv2GSdQ1dvwp 2dnkneg+1U+kGF3h9qBzgv1UP6JmrScylpiaskcy9jxHyxsrq5dI5zVV7/sRrp4T4v n881aOoHkBtHA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9880F18003E for ; Tue, 16 Dec 2025 04:08:50 +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,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-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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, 16 Dec 2025 04:08:50 +0000 (UTC) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-78c35dc5806so39055717b3.1 for ; Mon, 15 Dec 2025 20:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benramsey.com; s=google; t=1765858124; x=1766462924; darn=lists.php.net; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=dpplbne311Zb4e+HyiWEQG/H9FdVz545H25JRiPKyJA=; b=hk2FzqdbsWz4ircmli/PekaUybxt2bkgEMeA+QBzDTJvgodYotIBiSgbLeZse1gJCn MHl0az/dJUWZhC37a/WvJ1hpbzxEmqpJLIoB1fP1HkrEosBqAtgtTjIzG1TSCkm0V27l +SYPLiqgjoF5E4ZfRcmDz3VxRM31F0UnTJBLGzTxygMaYiOI/c1extYXxahovBy0UJJ4 hXstvBzTPiT0P+VYKSa3znREiX/70G2v4IwU5DnaxcSIjWufJSfWhqRBF5Xw0OFbwNX/ Who2kCCXoxjlU/ouHl+H5jYGiSLwUqhN4xoUhM37rWDoPXxPo7SVQ9qGi5i5rnfiYzCR nK8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765858124; x=1766462924; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=dpplbne311Zb4e+HyiWEQG/H9FdVz545H25JRiPKyJA=; b=K7NItrM47l2gk467Cw/bLHcsxaPnoacJkjAkmCHRkG/dTFrq87djwyK16EnEtXWbVn i7y1x9Hu5jsKm14yJnC84mzrN9sv3vEFatMxkxfjelFDlMXSBBCgqaJYElL/CcNPpCBX JWBbdCQgpdWX2xVV5zoTmqwyl5kE7rAGCQdDlYXLTahQprJYameJxzUzOHR1pBm5N6Ht kypDe/ViLVmj5yYzzVMS3ToSNkACoUgMhDmIdNmawx0MPMSYyjpTt8J+usdhz0iaCnjl dd7ILncEyDcV9B6dnCSUKcGwhovPTLSbV5mExNvYklUwpKVPcCuZxiTApUQF3MUFZb7N 72Ew== X-Gm-Message-State: AOJu0Yx3eDFki6cum7PkmIDkmBihAQy4xm0mduEnh7KPb6NGYPZ1el4U r8hrffxvx4NUW9vMV/2rtzKRFKISEMQv4utLHF6F5D5KRO1Kb91AoIeVvzLO/UVdRZ/qScSlapZ boKg= X-Gm-Gg: AY/fxX4hj8zXu+B1gR9WRBaIIWbfFMqw9zOVnoWpX3ePfNTAw9EQIVR/Se/jTO4rbDw UyOljl98ewcuYRIWxLx4FeVC4BA31931wbM0acvzIt8iFg6tJitjIDFrNjOWoEu6jitP7zm29Pm gpF07d4q6Q7kicfJam+0y7uT4ICKNeJRgoNjpKTkfDzFtxemWgFwSXuD1rOm8Kt2tlNWvZaEJIS SzuEzxlGNt7enhiIvM80mQtJ1d5gKhbuXA0gnFMeSKcFmj60Q+qMDjy+JvsFVrZz/GPe4jcqxwM Wfb/7mI3PnH3jMGXA1qEYHTwYoQJ3+2NGa56UKjCokTyx2GknkLsvc0QfH0QBh4VD6TpudWWoXi 6/U609fmYXzQH3xxbNujexXQvxg+KgKCEfmAIGXcGf/Vy1J6Wj4A+gNhiWbGo9UilJbVpQTVCTn ApQEK364f1oES/tCWNfk4FeqN46XbuBQBNQpIf9yu1nNzckTV6SN0Iw75jmE2PSDJhldZQlcjPy eZZASUCS1Q= X-Google-Smtp-Source: AGHT+IGUX2kqHFt4RjeT0exQp3f3FHnsOPvFT9xvMoVRwTWsTHe10mc8OFjYMXH2PZwFGIfsmnU3CQ== X-Received: by 2002:a05:690c:380f:b0:787:f117:f27b with SMTP id 00721157ae682-78e66c74f0amr101952687b3.64.1765858124404; Mon, 15 Dec 2025 20:08:44 -0800 (PST) Received: from smtpclient.apple (h96-61-170-179.lvrgtn.broadband.dynamic.tds.net. [96.61.170.179]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78e748eb402sm34952847b3.13.2025.12.15.20.08.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2025 20:08:43 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [PHP-DEV] [RFC] Context Managers Date: Mon, 15 Dec 2025 22:08:33 -0600 References: <70A79513-5503-467E-BC6F-2B0494A3EBB9@benramsey.com> To: php internals In-Reply-To: Message-ID: X-Mailer: Apple Mail (2.3864.300.41.1.7) From: ben@benramsey.com (Ben Ramsey) > On Dec 15, 2025, at 18:21, Deleu wrote: >=20 > On Mon, 15 Dec 2025 at 20:01 Ben Ramsey wrote: >>>=20 >>>=20 >>> Since the only feedback on what to use for "as" was that =3D> makes = sense, we have changed the RFC to use =3D> instead. So the new syntax = is >>>=20 >>> using (new CM() =3D> $cVar) { >>> // Do stuff here. >>> } >>>=20 >>> Going to be controversial here, but this is confusing, because it = operates in the exact opposite of every other usage of =3D> we have. = With associative arrays, the left is assigned to the expression on the = right; with arrow functions, the return value is the expression on the = right; with match, the expression on the right is returned.=20 >>>=20 >>> This is going to be easy to get wrong.=20 >>=20 >>=20 >> I agree with Matthew. >>=20 >> I think it makes more sense to reverse them, like this: >>=20 >> using ($cVar =3D> new CM()) { >> // Do stuff here. >> } >>=20 >> I think it=E2=80=99s still clear what this is doing, when reading it. >>=20 >> Cheers, >> Ben >=20 > I also agree with Matthew but the reversed proposed here looks very = very awkward to me. I think the most natural thing is the =E2=80=9Cas=E2=80= =9D but I may have missed the discussion on why it had to be changed.=20 >=20 > Thinking of foreach ($array as $value), an item from the array (left) = is assigned to $value (right). That seems symmetrical to using (new = Manager as $manager) where the instance (left) is assigned to the = variable (right). Also when using aliases on the top of the file =E2=80=9C= use Foo as Bar;=E2=80=9D as is also assigning the left to the right.=20 This argument makes sense to me (i.e., using `as` instead of `=3D>`). I=E2=80=99ll go back through the thread to find the arguments against = using `as`, to understand why it changed to `=3D>`. Cheers, Ben