Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124562 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 qa.php.net (Postfix) with ESMTPS id C93021A00B7 for ; Tue, 23 Jul 2024 16:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721752137; bh=bDfunh4F7Wj2A9bbyMcnIIQixaBP7Ajd3TPNcc0M7kI=; h=In-Reply-To:References:Date:From:To:Subject:From; b=kKOTRNu+XT9S/sOOqUcfPsDC8itCfvxHWDFN7T2rI7lctHKSX/n+Z2PnARbx9qSAG V0YNUx3pRxZqIqtAM632T3ODV7S0t1WZwcuWk6MlR68ltUWvpaQkpap4DzzDuANXyl ZxL4alMLbRkTCrvp6aMTRhTEDlXJt3t7REoOY33wHs7N9aibe3m5urmEGFrnMvbEKF 6diMsChlg2ZP9CLFAAwZGN087KS/bxUl4ht8u56jrPfk57v1stOEpZLeBajBPF9pjS rIfJ5xtOGqF0aY97bxC69Lp5ao/bK3G6F4V2xZ5ITETdzca8fk6TCz9DkS1cODsbL7 Po9IP57l3Y9KA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 552C318005D for ; Tue, 23 Jul 2024 16:28:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) 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.0 X-Spam-Virus: No X-Envelope-From: Received: from fout3-smtp.messagingengine.com (fout3-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, 23 Jul 2024 16:28:55 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 7B0211380191 for ; Tue, 23 Jul 2024 12:27:20 -0400 (EDT) Received: from wimap23 ([10.202.2.83]) by compute3.internal (MEProxy); Tue, 23 Jul 2024 12:27:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc: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=fm3; t=1721752040; x= 1721838440; bh=3Dklpkz6+hBkF0M+H02Lz2PTtHSmCPbP4ytHzdCWNec=; b=X lEmPOtZ10OuOfs7f71+fC34llb73K0d/PFgo5p5+2DEYFhMZsf1PvzBym3idSJVU WWFAlo8Met3Fuo8MQBsZjyRWfEqN7jUBL4jSgMDcvTZ+PI6JCybYgdm8F38xjT+H a5bRMsIs37gVHsKDXLwmXQx7fFglmKCdIpCN/O8KNhAl4mshrb+V00bKz31sDyfa EBX2EIV/uMDPCXVJs/PyUf231+KYpE17VCO0cA+uoQyTJnn23hzLGurtGPhyremw f6KVgFJ6I/zUqWjoeM3X1DkfnNCgmmKM3WGFiNMuUFpx0wKD6rl4ha5g4KU1Qok4 6lnkhqMvLr2nzON6gSZ1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1721752040; x=1721838440; bh=3Dklpkz6+hBkF0M+H02Lz2PTtHSm CPbP4ytHzdCWNec=; b=lGHtWLYkv5vIwU5gHTJuPtVHhgxE7xzsgB1IerKX0S0x P1iaBEPXwjocoz3/kVEo0sSXwDK0zNpHJmmI73S5CAXRgiloKSnBgHyd5bqZTKMB 6Gvq7THEXS5DqheDgcUC/FBior2a1vjAV6B3fDGquCJWaazQjkyjR6+PqbrD4gb1 SJwQRECC5mVJRvPEf3mK/aN2jYmD9lqsEFg1W/t/zQvkhlTP/d+MrM7kX9X66ago qoucrkHAPYpFIcu9zrJB/s3XrNW9r3xX8UwgCVyUKDoWyyJA9egfjYkTZTOe0KGm /YJoSl6Sj/96aSrkYvpym5pSm2q/RFNwmknA/vjy+A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrheelgddutddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghr tghpthhtoheptd X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 38DC02920062; Tue, 23 Jul 2024 12:27:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-582-g5a02f8850-fm-20240719.002-g5a02f885 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Message-ID: In-Reply-To: References: Date: Tue, 23 Jul 2024 16:26:59 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] [VOTE] Deprecations for PHP 8.4 Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 23, 2024, at 4:00 PM, Matthew Weier O'Phinney wrote: >> However, a few people indicated a desire to have an explicit wildcard _ anyway, even if it's redundant, as it's a more common and standard approach in other languages. We've indicated that we are open to making that an optional secondary vote in the pattern matching RFC if there's enough interest (it would be trivial), though I haven't bothered to add it to the RFC text yet. >> >> Having _ available could also be used in other "wildcard" or "ignore this" cases, like exploding into a list assignment or similar, though I don't believe that has been fully explored. > > Can you provide examples of what that usage would look like? And the > question I have really is, does this actually _require_ using "_", or > could another token be used for such matches? Hypothetical pattern matching example: $foo is ['a' => int, 'b' => $b, 'c' => mixed]; That would assert that there's 3 keys. "a" may be any integer (but only an integer), "b" can be anything and will be captured to a variable, and "c" must be defined but we don't care what it is. The suggestion is to basically alias _ to "mixed" for pattern purposes: $foo is ['a' => int, 'b' => $b, 'c' => _]; As "there's a var here but I don't care what it is, ignore it" is a common meaning of _ in other languages. But that would need to be disambiguated from a pattern saying "c must be an instance of the class _". Technically any symbol/set of symbols could be used there (as it's just an alias to mixed, which has the exact same effect), but _ is a common choice in other languages. In theory, that could be expanded in the future to something like (note: this hasn't been seriously discussed that I know of, I'm just spitballing randomly): [$a, $b, _] = explode(':', 'foo:bar:baz'); To assign $a = "foo", $b to "bar", and just ignore "baz". Which might cause parser issues if _ is a legal class name, I'm not sure. There's probably other "ignore this" cases we could come up with, but I haven't actually thought about it. Again, whether any of the above is a compelling argument or not I leave as an exercise for the reader. --Larry Garfield