Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123764 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 996CC1A009C for ; Sun, 23 Jun 2024 16:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719159885; bh=IhaBdx7fY75zeLForkjeeOy8n4LKr7R9Fo0oQauFcxo=; h=In-Reply-To:References:Date:From:To:Subject:From; b=d7ViQJ7oJICW1w1DsJjV2G6OqcAV+REEWJrxTPwk9v6B8pUozeiXaMmj/y7fzscXR fbCxols8kBhMgcqHt+djAAYG3wBKbg782X12W3oH8Mcj4uNfGQDRRpDL0lTG/AFAHa E93ZC++32vp96wqf/JuG73D8RLwElDB6ILVtHHsxDKlA76LCiGcltRW5GMRj8DbAeo muIBBo/wdg9+VhlEW2Ni9n+uWxMMYXjKEp6TbJRNnhhbAyj3NgcNXKnKqXbdLJ654I czeEdUiLSJ7nSr6wz2Tn9JFncmY/jdVvFV2EhtrFOr0uQ2e7FVn8TkKmWK/FeKARQe QuVo/kDWEhkZw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4475418005F for ; Sun, 23 Jun 2024 16:24:42 +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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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, 23 Jun 2024 16:24:41 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id AF3DE1140173 for ; Sun, 23 Jun 2024 12:23:25 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sun, 23 Jun 2024 12:23:25 -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=fm2; t=1719159805; x= 1719246205; bh=IgrJu+Yeo9z5rxaB2Wnsdc0BZ7GBcjwtgzqusBok/S0=; b=r yXpARef+A1DKgG5eNfP17gQ+Fn/fv3fXjxYV6ofm0GTrT0SdOB38OmHfJw7C358W C+qqi9539p67PS3GuUczSG5kmYIk43sRTm+NallQ3Y1cOMfmTjnIDL2kxTfFfPTh whI6zFuCWxSODc8G9K8jNg3BYGVHIhbozFeNYcp8nOhYwHCshM81d9SMHdLUwdJj xFLnskHRVP9XoUUV0mDD8FA22zHcYV9zW07S4pC4JXz7Chx7i/JtMIoWSiswtc83 ORKUYx5OQkpBmHLKt8W7rR7HnQKwcvq3bLal4Hekyq4cmpe8gAw5dTOcejslKKNo Ye5NhQA0JKz/uMcj6AYOQ== 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= fm2; t=1719159805; x=1719246205; bh=IgrJu+Yeo9z5rxaB2Wnsdc0BZ7GB cjwtgzqusBok/S0=; b=Gt9jLNpOGv/YzoTEuvw72LDpFqFJkOuprNn5T9MPsxf9 gqZ4Ex9Dk/Zta1+Da0NH+z1SVeo9FXFy7fCQCoEv9gsYgm8HgM4uTw8buxo31zwk cNUf1ikFiTz1pWr3euKizd0UdUKeGKPaj7LnunkfFP0ijrXSaGhjhD6HOy2J03CV a8/mvksSI+2X6vxFRKuByB/FpXqrEuLM+XUPrqEn5cTW5ladDWBgwjDBNyy8hquL xoMqc4d1PvZtYN+6dqzGNWY05ZP/LKok73k6vO1pNZnJFXeoTGRA529X4e9S1rIL lqxuy9S9TBCLfajpO91Qu5T50P36lVGCvixT7o6gjQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefledguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6137F1700096; Sun, 23 Jun 2024 12:23:25 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-522-ga39cca1d5-fm-20240610.002-ga39cca1d Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <5f31362c-fef3-459f-99d4-d73f73b585e3@app.fastmail.com> In-Reply-To: References: <2a6b92eb-d5e9-4a1a-9548-a068ac42ebd2@app.fastmail.com> Date: Sun, 23 Jun 2024 11:23:05 -0500 To: "php internals" Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Sat, Jun 22, 2024, at 12:14 PM, Brandon Jackson wrote: >> To clarify here, these all come as a set. Array shapes aren't their own "thing", they just fall out naturally from array patterns. So it's not possible for associative patterns to conflict with array shapes, as they are literally the same thing. :-) I'd have to check with Ilija but I don't believe there's much internal difference between list and associative patterns. This one isn't on the ADT hot path, so it could be postponed >> >> I see no way for associative array patterns/shapes to conflict with generics at all. > > Thanks for the clarification. I was looking at the example given in > the overview trying to figure out the boundaries between array > structure patterns, array shape patterns, and nested patterns. It > sounds like it can be summarized to nested patterns with the option to > add or omit `...` determining if unexpected key/values are allowed. > Also again, just throwing out hypothetical curve balls that could > delay or halt other good parts. At this point I don't actually expect > generics to ever be a thing. To clarify a bit more: There's really only two slight variations on the same pattern for arrays, list and associative. In both cases, each specified element of the array is matched against its own sub-pattern, recursively. That sub-pattern may be (almost) any other pattern. So this: $arr is ['a' => 'A', 'b' => 'B', 'c' => [int, int, int], 'd' => string] Is entirely valid, and decomposes to: $arr['a'] is 'A' && $arr['b'] is 'B' && $arr['c'][0] is int && $arr['c'][1] is int && $arr['c'][1] is int && $arr['d'] is string (This is why literal patterns are basically non-negotiable. On their own, they're kinda pointless. As a sub-pattern of another pattern, they're mandatory.) Array shapes aren't really a feature per se; they're just a natural fall-out of the recursive syntax. --Larry Garfield