Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123745 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 9E36A1A009C for ; Fri, 21 Jun 2024 22:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719010776; bh=ebDF2SvS5AuB2rcrqXJePvEiclkPlnKqkBmHfslmNlk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Y0Z+RkJRKkQNTW7gfAmAJdgm9tq4B47eFZ1jPCDUGOpGpjn+aMjpqnfTSrqRfriDi oeo7oq3BY58fJFb6fLK8ZOjzRTBCMZtE4RhqLOty49G3yd7bC7EoPAMNwU63hCKbFK hVQoR+kjrq7Q7pmoqJzR+OJfbn+7a30XNsesrpfvh9Gej5Kt5ZEsU03CEG5UNgHBev 32xC5sft7DDavbokjL3VvhZQ9EmpvUZLjK+EzdJJJ6UHRmEW6DRL04YWXa+zJk47mD MynEfIom48MnIoYiDjd2HG1FewG80B1hA8bI6rHQ+yLgbJjV75+D37wkp1Z/eS88tJ Y1xFhk60UehhQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 46F3A1806B1 for ; Fri, 21 Jun 2024 22:59:35 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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 mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 ; Fri, 21 Jun 2024 22:59:34 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52cd9f9505cso1106280e87.0 for ; Fri, 21 Jun 2024 15:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719010698; x=1719615498; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UYEkHZJoJ2YWAT7+f/NLt/XYRDo5nr5wRf9u7SBayTs=; b=J5V9Gba7OuH444brjVj2P4yhCf6jq4xBjIZmk6QQBNXOgXY1t+PK1KApoAeIXMqHjd 67NwLI2T/Bv+XQ3Y4EWbHWr+VVZqR1xTqDPcDyMh5WSCnmUhfBOXtXF+3DpDR4IioaNT PZuCtYBg9hmQ4CuQyy41CdsfYsMR0UGWlOMQhL6lr6vDbVQvPH7axNs56sQImjBCf8Xh qrlqtxUjlhyf3YgtEQumH9UTqTF12W5bBTkZrjbhBJwdDi77scSJMNcowix2KUyafp56 JhAh0iNmuPLD3QfCZ9w5CC2ELy7x2u1BVQiMWkBx9qkFsNAOOZ/MK/pSDMttikM1MmAe gUIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719010698; x=1719615498; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UYEkHZJoJ2YWAT7+f/NLt/XYRDo5nr5wRf9u7SBayTs=; b=xBa+4rm/OC+DfK1+2Y80M9pT5nIxdMTWS9M4rkBIz6OI3OcgTEQQeBdsDeot2S5Gla 55VWxxNxC0vdeMnwESWr7TKWaDsSe7KLWn1mTXHXGW/tcPCbABnlW/N9fiVvDMbGBVLO 9WlFCTnP45HHXubbYIlqbdhXx7aK1TQlZFl0A4f3U8aaoUy9n9El3rV3S+US91n9be6N htEFCiF8ZbaUUZrecb54Yog65wR/jgZ1D/+/IU1ZcvYnXz32nXkRifHCk3RYdysSsw8+ sNMlYxi3Qbp9yzmGWOH2G6itViH7KYucbz0pnxUgvEZOCOsTZyeGeME3igMi82Jh6VNC Ue2A== X-Gm-Message-State: AOJu0YyD4WZ1BHNlGhWTwlrXo7FA2Db4e1H+K44Zskwzbasm7nPPGyTi Q+eL+TfQLRCjZ5f3hFfVWFcopEqoeoqB6SoYIYQrUHCyS9WfJcP2EfGJF7zIg1U2+LOCcjspe23 8byf1YRYW2HDG6JfFF9wNi59tQN5UeWigeig= X-Google-Smtp-Source: AGHT+IF8DWhz06KMLdQGy6OM0XYrVbFypLSeii8xiqrmbBQB5kcjtjk78reXD+lG30NirS+iNCOwtpiyI39wbPe4E4E= X-Received: by 2002:a05:6512:281e:b0:52c:a016:5405 with SMTP id 2adb3069b0e04-52ccaa5867fmr7224709e87.8.1719010698156; Fri, 21 Jun 2024 15:58:18 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <2a6b92eb-d5e9-4a1a-9548-a068ac42ebd2@app.fastmail.com> In-Reply-To: Date: Sat, 22 Jun 2024 00:58:05 +0200 Message-ID: Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Fri, Jun 21, 2024 at 9:33=E2=80=AFPM Larry Garfield wrote: > > On Fri, Jun 21, 2024, at 3:35 PM, Brandon Jackson wrote: > >> Ilija and I have been working on and off on an RFC for pattern matchin= g since the early work on Enumerations. A number of people have noticed an= d said they're looking forward to it. > > > > Hi Larry, I have definitely been looking forward to this. Perhaps more > > so than property hooks and avis. > > > >> By "very high level," I mean, please, do not sweat specific syntax det= ails right now. That's a distraction. What we're asking right now is "whi= ch of these patterns should we spend time sweating specific syntax details = on in the coming weeks/months?" There will be ample time for detail bikesh= edding later, and we've identified a couple of areas where we know for cert= ain further syntax development will be needed because we both hate the curr= ent syntax. :-) > > > > I think that a lot of this would be best broken up. Although much of > > it is aimed towards the same general idea, a lot of the pieces have > > specific use cases and special syntax additions. Overall I think this > > rfc should be simplified to just pattern matching with the `is` > > keyword with the patterns limited to what can be declared as property > > types (DNF types) and future scoping everything else. Maybe possibly > > with the addition of 1 or 2 of the top requested `is` pattern matching > > capabilities as secondary votes. > > To give more context, as noted, this is a stepping stone toward ADTs. An= ything that is on the "hot path" for ADT support I would consider mandatory= , so trying to split it up will just take more time and effort. That inclu= des the object pattern and match support, and the object pattern realistica= lly necessitates literals. Variable binding would also be almost mandatory= for ADTs. I'm very reluctant to push off anything in that hot path, as ev= ery RFC has additional overhead, and I'm all volunteer time. :-) > As a user of PHP, this statement concerns me. I don't want any features rushed just because someone wants it "now" and thus end up with something feeling half-baked, missing important features or not completely thought through. I think it's pretty fair that this is a pretty big RFC (as in scope). Were it a PR under review, I might would ask you to break it up into smaller PRs because it's too big to discuss properly and were it smaller PR's we would probably arrive at a better solution than the giant PR. Perhaps, it might be worth breaking up into sub-RFC's (is that a thing?) where each pattern/feature can be discussed independently and the vote is whether or not it gets implemented in the parent RFC but has no binding on the parent RFC. Some things may be easy to discuss (such as type matching) but others might be longer (such as as, or arrays). But (and this is the key part) it wouldn't stop you from proceeding on the parent RFC, which is implementing pattern matching (in general) and any passed sub-RFC's. Maybe that could be a path forward? I don't know who makes the rules, but they're human rules and they can be anything -- in theory. Maybe "sub-RFC's" needs an RFC to define it, but that might let you move faster than a) trying to do everything all-at-once, and b) let hard-to-define parts of the overall feature get the time they deserve. > > --Larry Garfield Robert Landers Software Engineer Utrecht NL