Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129919 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 4B32E1A00BC for ; Sun, 25 Jan 2026 18:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769366450; bh=VL1sIojbmQ1lVrR+8glTvSqbpzMgwzC2zD8YoKyc6ck=; h=Date:From:To:In-Reply-To:References:Subject:From; b=W1ntTiyvpF6X2CVR3ZARQXmDpPyOdPrUj7XXRzxyxvg1kxQm+P0WMlAyAAmo5Ujsy 7W9ll1SjBjxIQBg1x7qPUeUCEt/+qQ7VLaJOewFJLMwIEloc9VoeI2fuMOVRMSk6rg ejmSKvGO2EuTKv6hx7xGsZy8P3Z2m0zMP2bIGaYGlpl9CePifR/5F6edAxtCHvri+w 3ooMJwxjJhsEceRsYyYIDTuWH4SnLTGimg+FytY8RKqYmXA2tC1QRMp+Tl9aDtTxnv nCpjtv73EPeWnuOfJGB7rbr+L5O+zJwElmBAgY9k7uAXbKbk1ALx8EJiCOfJMJmYXN AHP2idM0GKTGw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C829D18003B for ; Sun, 25 Jan 2026 18:40:49 +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-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 ; Sun, 25 Jan 2026 18:40:39 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id AD81A7A0050 for ; Sun, 25 Jan 2026 13:40:33 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-02.internal (MEProxy); Sun, 25 Jan 2026 13:40:33 -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=fm2; t=1769366433; x=1769452833; bh=zMohcyBvO91Hzw5hEdS/T BB88U1L2wTdci/9o7ewt48=; b=rC1Mut11MdrGtEMX/+6h6aObSrfk0R0GGdwrA pXdfZeHzzC1t074MkY7RZ5gsCPKEzNraTvHm8Os+7Ce2lMfGbPs/8ee7TIYod9+Z QStecolqcT61yhc3RZ0TzJhCYHIOcyggY1kNgPd/lWkpnmYr1Y/NFESr8cEQqhKs H1LGxH9J1enizB5gpDic0ZdSWh2wCSYcMsWr2fHAehXvG88l3QHm8gi/yJjRsQC/ qCXgYYwsgjPqEjZ29atDq3J+PmT+Eofl8l1K3G9XKJasoInwRf+zKnCBAxonAmUy PCJvoejaag39Kf1ERyMQkmx4+Bbp0tKRZ64VoRgO5ESoehb1w== 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=fm2; t=1769366433; x=1769452833; bh=z MohcyBvO91Hzw5hEdS/TBB88U1L2wTdci/9o7ewt48=; b=r/xtWR7Dj3hY3VNSI h4XNzOl46DYdJ25ZMmmuSm9E/Ys+BPemui689cco3Y/IJWZSK/BX5bNyPEj2WoUZ zyEJ0l1WOMrDNYyVcPyRuX9Ncs+Ws/E2N10RorYLwRgMLX9ZsW5SqXR2yhCV6cLP 8s8m8W4YfwGEzhrn7eMEd37pBWNQdgZjljMKdScUAzpQ381tNua5gJT/BkILS4pA 7QUFkh853CaKnz7WgLPclF4zTpgEB1IgcmbEC7wDndd8hMl52KW/Btou1R5sMGmK Hnw8j1Qvbm7jcIgQ7zujKrWJ1op43f/wdembk7m5bZBtotPMTIQ1tGH7awmNUbb6 3ZSkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduheehheefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeet udeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 66C2E700065; Sun, 25 Jan 2026 13:40:33 -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: AwYpyWzRIPe7 Date: Sun, 25 Jan 2026 12:40:12 -0600 To: "php internals" Message-ID: In-Reply-To: References: <3665e8eb-db54-421b-8ffe-e3b1902caf09@app.fastmail.com> <48689ab4ab0bb680ff9457e406490fa5@bastelstu.be> <3afc1bd6-7515-4ae7-a2d4-dd4e08917746@app.fastmail.com> Subject: Re: [PHP-DEV] Re: [VOTE] let construct (Block Scoping) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sat, Jan 24, 2026, at 12:16 PM, Tim D=C3=BCsterhus wrote: > My understanding the initial paragraph of your email is that the entir= e=20 > functionality of the block scoping RFC could be included in the Contex= t=20 > Manager RFC. The Context Manager RFC uses the same "high-level" syntax=20 > of having a dedicated block for declarations - just using `using`=20 > instead of `let` as the keyword and using `=3D>` instead of `=3D` for = an=20 > assignment (the latter of which was considered confusing in the=20 > discussion). I'm sure I must be misunderstanding, because I don't foll= ow=20 > how the syntax of this RFC is "non-standard and clumsy" without this=20 > equally applying to the context manager RFC. Can you rephrase? Block scoping and CMs are related and overlap, but are different things.= =20 `let`, in every language I am aware of that uses it, is an inline part o= f the variable declaration, and then they do something to resolve the "d= ead zone" question. Languages that have block scoping have had it from = the beginning, so "variable dies at the next }" is built into the langua= ge semantics and development culture. Neither is true in PHP. So havin= g a block-esque syntax for "only these special blocks and these special = variables get block scoping" is something I have never seen before, and = feels very clumsy. CMs are about packaging up setup/teardown logic to make them reusable, a= nd therefore more ergonomic. That setup/teardown can and often does inc= lude unsetting variables, but that's not its main purpose. It's just an= implementation detail. In every language with such functionality, it i= s a block level construct. Block scoping as presented here is essentially a "junior, limited CM", w= ith a future scope of adding a Disposable interface to make it a less-li= mited CM. I fundamentally believe that is the wrong way around, and hav= e already discussed elsewhere (I think) why forcing the context manager = (packaged logic) and context variable (the variable(s) that will need cl= eanup) to be the same value is fundamentally limiting and flawed. I proposed allowing the `using` syntax to handle non-CM objects specific= ally to incorporate the "degenerate case" where unsetting is the only me= aningful teardown, and thereby avoid the need for a boilerplate new Just= UnsetTheThing($thing) for the degenerate cases. CMs can also return $th= is from enterContext() if appropriate, which would then have the same ef= fect as the Disposable interface. So no matter how you slice it, having a separate CM from context variabl= e provides more flexibility than the proposed `let` syntax, in a consist= ent and unified fashion. By tweaking CMs, we can allow it to also cover= the simple, degenerate cases that block scoping handles in addition to = the more robust options it naturally supports. > I'd also like to note that it was an explicit design goal of the block=20 > scoping RFC to compose nicely with existing control structures to be=20 > generically applicable. This enables several of the example use cases=20 > listed in the RFC. The context manager RFC requires braces and a=20 > proposed special case for `try` instead of just accepting any statemen= t=20 > like block scoping does. Due to its composibility, the block scoping R= FC=20 > is even compatible with future additions to the language (provided the=20 > future additions follow the established syntax). As an example, patter= n=20 > matching comes to mind as another way of "writing into variables". Blo= ck=20 > scoping will just work with match: > > let ($x, $y) $result =3D match ($p) is { > Point(:$z, :$x, y: 4) =3D> "x is $x, y is 4, z is $z", > }; > > to prevent $x and $y from leaking out of the `match()`. And similarly = to=20 > the `foreach()` future scope, we could allow `match ($p) let is` to=20 > automatically block scope all variables bound by the pattern. thinking_face.gif This is sort of what we were trying to noodle through with the questions= about expression-oriented `using`, but it didn't stick. I would have t= o talk to Arnaud, but I suppose it's probably possible to allow `using` = to work on an arbitrary construct and inherit its block. I'm quite open= to discussing the feasibility of that. It's really unfortunate that both proposals were worked on separately, a= s I do believe there are good ideas in both. But I would much rather wo= rk from the more-flexible design and then short-cut the degenerate cases= , as that gives, I believe, a better outcome in the end. --Larry Garfield