Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129618 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 77EE41A00BC for ; Tue, 16 Dec 2025 09:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765876033; bh=syE9i7FY/xTM0sBY4zwSowws+GrlQMMS02S/35rrcwk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WBcMFG/u9mJWl8YLHLCG90kXpx0LwM7UWcmJx75Q8UmiennXDWGINwBlXNCmOqOyq zTGxOVETDBF2+f72kZ/RfoLIBs2vf4b+lU/37MqzCP6A4uRv0ewkEF56owUF7ZyCV+ WoCT6JEiHZ3iBvgTs5KLbZLgNzOzdL92nJjIg/z5UW80y2nAH4cav58p05gs8dbx3U oBzavsfYniFieNcPp4wCgce/j3Hj1ssV04Oxrm5egLESJGFCb4Krgrta5uwYDKdLyQ xM7jZdKpe9NdukcjGikOF6BzCx4cMzao4VXTeLX1dAIKJ7TC4EW9l8iezDUu2HRct4 s2Dw5cq1QV/2Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7170418003E for ; Tue, 16 Dec 2025 09:07:12 +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,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 09:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1765876025; bh=n4fc4DPRgZTFHN6KzJWR7lZQx4PUlLsdNU9TKXIluXE=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=Q9uI3USca4lmjvSF3vxlv/y86+4gtmK7lv+PJaz4Qir6n8CCMUsl8ehQ3igzTh+E9 9kbnmqVo8quWRwmpCqdVtawf+Cv2buUlJoG3BSsakFSq1DHG3sbyMozpgx+Hltj6yS 5qP7WxQaFJtezAHipmI0qg+/seM828qm9QRRF0aKPr6FkbnTqzTDSfYwjD0g82t7hS rPANa5UkcOnZ+VTYhyUFE9s6c8nEPOIq669YZfyICEM4fHNrNCFI6MyIClxGEmrsEw FeZQX2yU1PCCZXqMUdlyQfxw6WEtJz9pcS7/vUu2ORyJDrzlVwlh60SQYFqhuV9WCw mGMipDIJGO4Qw== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 16 Dec 2025 10:07:05 +0100 To: "Rowan Tommins [IMSoP]" Cc: PHP Internals , Matthew Weier O'Phinney , Larry Garfield Subject: Re: [PHP-DEV] [RFC] Context Managers In-Reply-To: References: <70A79513-5503-467E-BC6F-2B0494A3EBB9@benramsey.com> Message-ID: <480eff88ceba74d3274917d6ce2a3c24@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-12-16 09:08, schrieb Rowan Tommins [IMSoP]: >> I also agree with Matthew but the reversed proposed here looks very >> very >> awkward to me. I think the most natural thing is the “as” but I may >> have >> missed the discussion on why it had to be changed. >> >> Thinking of foreach ($array as $value), an item from the array (left) >> is >> assigned to $value (right). > > > 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. That definition doesn't make sense to me. An iterator that only ever emits a single value is not actually iterating anything and it would never occur me to interpret it like that. As I had also noted in my reply https://news-web.php.net/php.internals/129582, it is absolutely magic to me that `break;` would target `using()`. > My favourite among my own suggestions was "using($cValue from new > CM())", but Larry didn't like the reversed order. I also suggested > 'using(new CM() for $cValue)", but I don't think that's as clear. FWIW: Using `from` would be somewhat consistent with `yield from`. Using `for` would effectively invent another meaning for an existing keyword, something that folks disliked for `use()` as the initial block scoping keyword. Best regards Tim Düsterhus