Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129629 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 810331A00BC for ; Tue, 16 Dec 2025 22:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765923743; bh=0UJAziPIImYiXtpdfxlIeWM8VHYPtqVeFiHEM83yrRM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=N63B4gBCFGG6OgVc3wd1p/LZr4qoDj28om1Qx8Vriy8cyQwmtu/0AWzQ4oCGRAiTA gzVIj1+AIGUTdATOBTDMurxAhCfkkni7S6IeXhsNTYiTQt71ly4iXiCtuGxCa5Raen Urr3IgDt3S3KO3qNfYFW5+qs6Wb3iWsLXtsuHq1/XfFVydXh9VplTu57qVsfW8HbLV eDoND2m0xVOwx/3CK9fWisqeWV8jy+oiP0SnKzCfE+GFTZuBSy2ux5z9O/II6ZpAB5 pId2L8qWwszIPLHMNowBPdWCDbXxEQ/prtqnyRoLwAr+EmC6c4EWY+cvF26mVg/4Ic x3yyNWThMleNA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 481A5180088 for ; Tue, 16 Dec 2025 22:22:22 +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 fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (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 22:22:22 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id CBDC2EC0073 for ; Tue, 16 Dec 2025 17:22:16 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Tue, 16 Dec 2025 17:22:16 -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=fm1; t=1765923736; x=1766010136; bh=EBJx0wUEnowNs3snjAql+ IqqzznMRY8geN34cjegxnc=; b=pA2hDACVNCnregUnp15E3Oa4nLPgRAuOgDgYa uhVO1NGiZQlrgHmk6r+fFGIfAjJjtmH3/XvqaEnPYmrtOf3HguNRGUBJwSX5kaqj XQgA5dc630nWj9VqN+OwrOnYm4qa23NvsBEGItim4Vc5afzeuquhZc/BFWJesKcg 9QNBeSCc7+ihGutQ8Ls89Udfm6OBSEQcQMGU9dFGAZxidY9/0rRs30UWn/yeprsn U99xvlrkphDX9qK9Cz9omGbsP4M0TsfIDVkquGGGzJs6ILvYJy7RI9Yv6o5buVCV UATl8q4SeUUSmzVmnbSkSJ4/V12/tly0AiGaC21hWDbQYh8Yg== 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=fm1; t=1765923736; x=1766010136; bh=E BJx0wUEnowNs3snjAql+IqqzznMRY8geN34cjegxnc=; b=DcnIRHfJ2LLYNpbj/ emmONLNZvSySQtYOwj7s6eZMnGkin4ZBpamLsotGVmwtdBRkr9xdwDc3GI7HzR68 AeaMQXUIbbbD3DNlnq4adxcKlbkiFlV71AAoMROZRWrj6SC2VddnMbMisahf4czI I9o2w6B18nbsGe41ASK7/a9JeHYX44vLnvJyYZop7uCu1Dmc14pWu7xwb8eiDA3K 0+G4YsFONua92vAwILmuXPBBdqIes53Ap5UNt0aZ8QMELgyan4X8T/UFusnb4FxU DP+PlBU25Z1WVPSgY2LqYpeXRnSWBpjXmrdTqfji8FwUfK8g9gEZ3hveBgo9h0QA M8euA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdegtdekjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepudegvdelgfeugeehfeejteffudevleethfefgeejffffleeg tddtveekgeekudfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 89A6118C004E; Tue, 16 Dec 2025 17:22:16 -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: ALvh3TDXSVwZ Date: Tue, 16 Dec 2025 16:21:56 -0600 To: "php internals" Message-ID: In-Reply-To: References: <70A79513-5503-467E-BC6F-2B0494A3EBB9@benramsey.com> Subject: Re: [PHP-DEV] [RFC] Context Managers Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Dec 16, 2025, at 3:40 PM, Matthew Weier O'Phinney wrote: >> If there's some better word than =>, we're still open to it, but I am going to insist on left-to-right reading. $cm is created first, then it produces $cv. >> >> 'as' is what we had originally, since that's what Python used. However, it was pointed out that it was confusing as it implied the CM and CV were the same thing, or rather the expression on the left gets assigned to $cv, which is not the case. Hence the change. > > I didn't find it ambiguous, but I can see where others might. That > said, I found it _less_ ambiguous than => here. >> >> A symbol does have the (dis?)advantage of a somewhat squishier meaning than a keyword. >> > I want block scoping; I have been bitten by accidental re-assignment > within a block many times, and hate having to come up with an > ever-so-slightly-different variable name to disambiguate. I don't care > if it's this proposal or the "let" proposal in terms of how the engine > handles it - but the syntax of "using (expression => $var)" isn't going > to get my vote due to how easily it can be written incorrectly. > > I have no problem with the "using (expression as $var)" syntax, and the > "let($var = expression) syntax is just fine for me as well. I think it's important to realize that the two RFCs may be similar, but they're actually doing two VERY different things. The `let` RFC is defining a guaranteed "unset this variable later". That's it. The CM RFC is defining a way to package up setup and teardown logic into a reusable component. That happens to also involve unsetting a few variables, but that's not its primary design. The primary design mandates the separation of the context manager from context variable. The CM RFC does substantially more than the `let` approach would be capable of, and is a model proven in Python to be useful and effective. (As I said elsewhere, I think `let` as an addition to existing structures would make more sense than using it for arbitrary new blocks, which would also avoid any confusion with CMs.) So are you against the Context Manager proposal entirely, or would you be on board if we can find a non-confusing syntax? Ie, using (new CM() which produces $var) { } If we can find a less verbose way to spell "which produces", would you be on board? --Larry Garfield