Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129616 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 80CCA1A00BC for ; Tue, 16 Dec 2025 08:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765872495; bh=+tI4u66LKQhT92YbmmM9LkwVXuHAuzMFxVzaIMaoWlQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=S+cHm6QWechT3XdQF3fRurMUBOuql+qyuEvCnR6EgRBxcckhTaOOYZTAymtHY2bpm 2QoL0D3EdkCpDlThZPdQzBb7V2BwROAtlZ16+P4FfcqFAy/3kiyM62Zy6MhdjDZL2x wpF6jzNTq9H9bNGVuM4Zyh1PFBFEEoXG/FEFyiX+sFsl2pxiIJMtkz+Tdek7xC4gEb tYQ294nAVwPZmbsauKhjroxcrCyenlST8nTVlLxou+vow3/WcZpu0j6N13T3dgToy4 hvzoprCsumaTpPXRTJcx5Qq+02MdgudY42Wn1v6dMk6CisODKZR4XmJdVWQZC7G7kD BG5Js7WReuvPg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F9F7180034 for ; Tue, 16 Dec 2025 08:08:14 +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_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 08:08:13 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 9D176EC01E0; Tue, 16 Dec 2025 03:08:08 -0500 (EST) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-12.internal (MEProxy); Tue, 16 Dec 2025 03:08:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :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=fm1; t=1765872488; x=1765958888; bh=j3RHuOlzVQKDkBPtaNenfdnXfepdWj25bU17uPMXFT0=; b= STEYconIqOvcP259BIAg7weAhrYlBBS05JkQ35SfVHQuDaVasIiGhAaIaSDsoMeV oIdcd7dHwJKe1kRD5zFy+czKBn+l0H986vee1p5kJdiLDgqRjPZoYPQaX86VErKr WMFfBEqv3StHmaqPRlkIYMdMT4IjTjobHfgcomXctXmpSB9WH6cx+JLRMsRWwyjH nyUvokX+0hkPDO6u92fZB8JnfU/8RvoiNs4B0kOK6X2kHz/Xbk0/TfaNG/3Hxwyu T0HZz9uchpFJAY/tWKZL+Ouu+XsTfHr2nG3RxUGzs7jU3plCALy81G9iHQ9QrolR apJ90nx+k84P19Gohzi3Dw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t=1765872488; x= 1765958888; bh=j3RHuOlzVQKDkBPtaNenfdnXfepdWj25bU17uPMXFT0=; b=r TC+5b06+iiIg/t7tY1FlzQp89XxwjipQtcoISEter0vyi7nlo0bSFWM2Pq/OzkJl QBHYqXmKvJy/ED8K6dd4gvbuFjZKpWB5CbHE8FoIn4YcjfjwN52bnZ7ksgIctaNO j7kr1gwvL3EAKbJW4/DeZP2GRcyJ8q3Bd5v18u5KXn7k6Bh8UYU6Ix/87axZS21Y fSEefKhZ1J6vhDV14rSzOJg/pKneYfCVSE4zCDg0gsE/VOkqvlpLhpc4w7N8uzj9 kVCra/CPj8VneEEkVVLfRJ9E7xC1Qo+XYD7bAUXxgcnrhyUQIlBTe4C4XtY8miy1 7P5ZEnVNkRc0oRHvkuoTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefleduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefufggjfhfkgggtgfesthhqmhdttderjeenucfhrhhomhepfdftohifrghn ucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtg hordhukheqnecuggftrfgrthhtvghrnhepuefgjeefgffhvdduvdeijefhfeefleeujeei hefftdegtddvteduudefudekueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggp rhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnh grlhhssehlihhsthhsrdhphhhprdhnvghtpdhrtghpthhtohepmhifvghivghrohhphhhi nhhnvgihsehgmhgrihhlrdgtohhmpdhrtghpthhtoheplhgrrhhrhiesghgrrhhfihgvlh guthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Dec 2025 03:08:07 -0500 (EST) Date: Tue, 16 Dec 2025 08:08:05 +0000 To: PHP Internals CC: Matthew Weier O'Phinney , Larry Garfield , php internals Subject: Re: [PHP-DEV] [RFC] Context Managers User-Agent: K-9 Mail for Android In-Reply-To: References: <70A79513-5503-467E-BC6F-2B0494A3EBB9@benramsey.com> Message-ID: Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") (Replying to a few of you in one go, I hope the formatting is clear)=20 >>> we have changed the RFC to use =3D> instead=2E So the new syntax is >>> >>> using (new CM() =3D> $cVar) { >>> // Do stuff here=2E >>> } >>> >> >> Going to be controversial here, but this is confusing, because it opera= tes >> in the exact opposite of every other usage of =3D> we have=2E=20 > > I agree with Matthew=2E > > I think it makes more sense to reverse them, like this: > > using ($cVar =3D> new CM()) { > // Do stuff here=2E > } It took me a long time to figure out what you were both saying here, becau= se to me the direction of the arrow seems to consistently indicate data flo= w: you call the function, and data comes out; you enter the context, and a = variable comes out=2E But I think I see it now: you're treating the context variable like an arr= ay key, that is somehow "bound to" the result=2E Except that's not what's h= appening, otherwise we could just use "=3D"=2E >I also agree with Matthew but the reversed proposed here looks very very >awkward to me=2E 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=2E > >Thinking of foreach ($array as $value), an item from the array (left) is >assigned to $value (right)=2E This is the way to read the "as" syntax, yes; as I've said in a few places= , a Context Manager is like an iterator that goes around once=2E > That seems symmetrical to using (new Manager as >$manager) where the instance (left) is assigned to the variable (right)= =2E This, however, is why it was changed: that is *not* what is happening=2E T= he Context Manager is not assigned to the variable, it *produces a value* w= hich is assigned to the variable=2E=20 Again, look at the foreach equivalence: you wouldn't write "foreach(new My= Iterator as $iterator)", because it's not the iterator that ends up in the = variable, it's the *items produced by* the iterator=2E=20 So you have "foreach(new MyIterator as $item)" and "using(new MyContextMan= ager as $contextVar)"=2E=20 But evidently that is not obvious to readers=2E My favourite among my own suggestions was "using($cValue from new CM())", = but Larry didn't like the reversed order=2E I also suggested 'using(new CM(= ) for $cValue)", but I don't think that's as clear=2E=20 Perhaps there is some other word we can use? I suspect it would not need t= o be fully reserved, as it's used in a very restricted context=2E Or, perhaps there's something other than "using" that clues the reader int= o "this object will be used to produce an arbitrary value" in the same way = as "foreach=2E=2E=2Eas" does? Rowan Tommins [IMSoP]