Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123811 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 7241A1A009C for ; Tue, 25 Jun 2024 09:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719306600; bh=WM1pnv6n2fvgYIdGB+4jNwz8njle/4N5CC97fYKrkds=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CR+oFDBCKaA7y0gbT67g4yx6rWj9A8FIfDK1qDxqd/6V0NFlMQemf3DxB9AUU5NOY 3M9jh/ibPF/CzznqjlGYi86TNi8kjYTzkKwmxM8QFNjPh7kr5V9tcZ2UpKPUU8ekZ2 CTeZ/iOiG5VvruPwWn7JDDTYw4o6NHAhRyJxh2Z2lvtsmpOg42JSkMuARvcDX2nh7U Eyj/K/GDz4F5SpUNl4nE6puFFObYYE2VWovrRi0BDK/AiJefRZwGi7nprQKsdv2aYu NIIjMIO/M9Q0xAw55NYPbmFBnf5ZpR9HI2EL2D0Vs8jopS2+l8mg+zTOhP3xf5wbBr XREdLc9rhkVUQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 19E24180341 for ; Tue, 25 Jun 2024 09:09:59 +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, HTML_MESSAGE,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-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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, 25 Jun 2024 09:09:58 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-57d0eca877cso6211716a12.2 for ; Tue, 25 Jun 2024 02:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719306520; x=1719911320; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NoTe7U3zE0x+uxD2ashsLnRzRxQFtMXxUUwTijUzMnk=; b=AZMLyVDS3QPc1IwrtYtBrOptoy4HPogL7zho+bSiwOJmc5bqKZIMazStsx8Du4g9qF yGCHY8gfACLIqByqxRhlWqi7+oZe7nitmIx0LLe70e9VNY0V9NJzf+BNwmyv01ZtDHSr rvFabQ7Jo/mMZgC59la5hphrh5lNvjNpiXdzDNlb0IlXoT3YyOK3X1PXHYNYCjbC45JA wJlmvgaXdCIoU+jSe19UbxBcJV+6ykB0UQVT6VIhCyPh765R9UyJBtlpXUtbHZ8Q5Qil MsIQHLmgNSr07YmHNOrtJ8wLKr1gVGfiteOJH+IK982l1ymz/SbjI4ceTiz/g24ztgmi 8IxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719306520; x=1719911320; h=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=NoTe7U3zE0x+uxD2ashsLnRzRxQFtMXxUUwTijUzMnk=; b=kKyPZiMk2YhjNrRROgZCWMQvgfS2d67dMHuMOC+d5E3R4Dm3yjqakctP2qL1/MaizL Esjw/aVDiJBULAs2retYBPFGUkDZ8DohRACsCD4rB6DK0y/tes35977l5qEollknfpWA 1uwmSeRHGYGzX3XPC7RFNinHFcqhdePcXdA8MjFRLLv4dKFR8Jw/nLaAJV9g0LcU+03c KcOEyg1gAZewFhmNUE6ueRBabro/yTI3vqxzAsO/xEH+7hPKOGFGsmPGDhwdTO4cwkaK iYbj3HKmCz0d/XJMbAMe3kL7zRX9uyEMpj45LZERe1eVo6JMGOWfv7TO4RghaMjQfYSj 5SSg== X-Forwarded-Encrypted: i=1; AJvYcCUFzi1BIo7ArzKlOcFwirbQP+FnOAT7oru/5fcubSG4VEyEEnHZUwsIdURuwJgi6LVRFYeGI7dednc9wYGV6JM1XVnZtFcZhw== X-Gm-Message-State: AOJu0Yycx2bTFnO5F7o/UF+yhmVM22QoljMbeVKpIE31kZPMwVetmqN7 afaqj+YV3ditspugDq19BVUXRNRd8+utol9JYI7Z8ckHdLoYuMWuraHd0wTC3KEXV5n0Uj2gkv4 971B0ntX2XkNdiSUKMGXCy4W45BTcg2FJ X-Google-Smtp-Source: AGHT+IECy66DkpVgZB19YJ3tzPSl4wOflPjcYBXrUEvMjZA6HW1SGhcy8JO5xS9rUzkayvsOmyzqndI6+41+uR32P0E= X-Received: by 2002:a50:d653:0:b0:57d:785:7cbc with SMTP id 4fb4d7f45d1cf-57d4bdbfae4mr5570898a12.26.1719306520279; Tue, 25 Jun 2024 02:08:40 -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: Tue, 25 Jun 2024 11:08:13 +0200 Message-ID: Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching To: Robert Landers Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="00000000000066c510061bb33ed1" From: kjarli@gmail.com (Lynn) --00000000000066c510061bb33ed1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 25, 2024 at 9:44=E2=80=AFAM Robert Landers wrote: > On Tue, Jun 25, 2024 at 2:48=E2=80=AFAM Larry Garfield > wrote: > > > > On Thu, Jun 20, 2024, at 5:38 PM, Larry Garfield wrote: > > > > > To that end, we're looking for *very high level* feedback on this RFC= : > > > > > > https://wiki.php.net/rfc/pattern-matching > > > > Hi folks. Thank you to those who have offered feedback so far. Based > on the discussion, here's what we're thinking of doing (still subject to > change, of course): > > > > * We're going to move `as` to future-scope. There's enough weirdness > around it that is independent of pattern matching itself that it will > likely require its own discussion and RFC, and may or may not involve ful= l > pattern support. > > > > * Similarly, we're going to hold off on the weak-mode flag. It sounds > like the language needs to do more to fix the definition of "weak mode" > before it's really viable. :-( On the plus side, if the type system itse= lf > ever adds support for a "coercion permitted" flag, patterns should inheri= t > that naturally, I think. > > > > * Array-application will also be pushed to future-scope. Again, there'= s > enough type-system tie in here that is tangential to patterns that we'll > pick that fight later. > > > > * Ilija and I have discussed regex patterns a bit further, and it sound= s > like they=E2=80=99re going to be rather complicated to implement. Even a= ssuming we > agree on the syntax for it, it would be a substantial amount of code to > support. (It=E2=80=99s not like types or literals or range where we can = just drop > something pre-existing into a new function.) So we=E2=80=99re going to h= old off on > this one for now, though it does seem like a high-priority follow-up for > the future. (Which doesn=E2=80=99t have to be us!) > > > > So let's not discuss the above items further at this point. > > > > * I'm going to do some additional research into other languages to see > how they handle binding vs using variables from scope, and what syntax > markers they use and where. Once we have a better sense of what is out > there and is known to work, we can make a more informed plan for what we > should do in PHP. (Whether using a variable from scope in the pattern is > part of the initial RFC is still an open question, but we do need to desi= gn > it alongside the capture part to ensure they don't conflict.) Stay tuned > on this front. > > > > * We've removed the dedicated wildcard pattern, as it's equivalent to > `mixed`. If there's interest, we're open to having a secondary vote to > bring it back as a short-hand pattern. It's trivial to implement and we > don't have strong feelings either way. > > > > * There's not been much discussion of range patterns. Anyone want to > weigh in on those? > > > > * The placement of `is` on `match()` is still an open question. > > > > * No one has really weighed in on nested patterns for captured > variables. Any thoughts there? > > > > * I=E2=80=99ve seen a suggestion for capturing the =E2=80=9Crest=E2=80= =9D of an array when using > =E2=80=A6 That=E2=80=99s an interesting idea, and we=E2=80=99ll explore = it, though it looks like > it may have some interesting implications that push it to future scope. = It > feels like a nice-to-have. > > > > Thanks all. > > > > --Larry Garfield > > This morning, while thinking about "new Pattern($pattern)," it > occurred to me: why not create an OOP extension of patterns? It > wouldn't need an RFC or language changes and would allow the > development of patterns to the point where adding it to the core > language may be a no-brainer. You (and other users of it) would have a > pretty good idea of which patterns are actually important and useful > due to actually using them. > > It's probably the "long way around" but at that point, you'd basically > just be pulling in the extension and discussing syntax as the behavior > would be well-defined and battle-tested. > > Robert Landers > Software Engineer > Utrecht NL > Are you referring to "new Pattern($pattern)" specifically for regexes (similar to JS), or pattern matching in general? Is this also pointing at putting the behavior of pattern matching in an object that effectively executes the pseudo code from the examples, with the actual pattern matching being a syntactic sugar to be added at a later stage? --00000000000066c510061bb33ed1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Jun 25, 2024 at 9:44=E2=80=AF= AM Robert Landers <landers.r= obert@gmail.com> wrote:
On Tue, Jun 25, 2024 at 2:48=E2=80=AFAM Larry Garfield <<= a href=3D"mailto:larry@garfieldtech.com" target=3D"_blank">larry@garfieldte= ch.com> wrote:
>
> On Thu, Jun 20, 2024, at 5:38 PM, Larry Garfield wrote:
>
> > To that end, we're looking for *very high level* feedback on = this RFC:
> >
> > https://wiki.php.net/rfc/pattern-matching
>
> Hi folks.=C2=A0 Thank you to those who have offered feedback so far.= =C2=A0 Based on the discussion, here's what we're thinking of doing= (still subject to change, of course):
>
> * We're going to move `as` to future-scope.=C2=A0 There's enou= gh weirdness around it that is independent of pattern matching itself that = it will likely require its own discussion and RFC, and may or may not invol= ve full pattern support.
>
> * Similarly, we're going to hold off on the weak-mode flag.=C2=A0 = It sounds like the language needs to do more to fix the definition of "= ;weak mode" before it's really viable. :-(=C2=A0 On the plus side,= if the type system itself ever adds support for a "coercion permitted= " flag, patterns should inherit that naturally, I think.
>
> * Array-application will also be pushed to future-scope.=C2=A0 Again, = there's enough type-system tie in here that is tangential to patterns t= hat we'll pick that fight later.
>
> * Ilija and I have discussed regex patterns a bit further, and it soun= ds like they=E2=80=99re going to be rather complicated to implement.=C2=A0 = Even assuming we agree on the syntax for it, it would be a substantial amou= nt of code to support.=C2=A0 (It=E2=80=99s not like types or literals or ra= nge where we can just drop something pre-existing into a new function.)=C2= =A0 So we=E2=80=99re going to hold off on this one for now, though it does = seem like a high-priority follow-up for the future.=C2=A0 (Which doesn=E2= =80=99t have to be us!)
>
> So let's not discuss the above items further at this point.
>
> * I'm going to do some additional research into other languages to= see how they handle binding vs using variables from scope, and what syntax= markers they use and where.=C2=A0 Once we have a better sense of what is o= ut there and is known to work, we can make a more informed plan for what we= should do in PHP.=C2=A0 (Whether using a variable from scope in the patter= n is part of the initial RFC is still an open question, but we do need to d= esign it alongside the capture part to ensure they don't conflict.)=C2= =A0 Stay tuned on this front.
>
> * We've removed the dedicated wildcard pattern, as it's equiva= lent to `mixed`.=C2=A0 If there's interest, we're open to having a = secondary vote to bring it back as a short-hand pattern.=C2=A0 It's tri= vial to implement and we don't have strong feelings either way.
>
> * There's not been much discussion of range patterns.=C2=A0 Anyone= want to weigh in on those?
>
> * The placement of `is` on `match()` is still an open question.
>
> * No one has really weighed in on nested patterns for captured variabl= es.=C2=A0 Any thoughts there?
>
> * I=E2=80=99ve seen a suggestion for capturing the =E2=80=9Crest=E2=80= =9D of an array when using =E2=80=A6=C2=A0 That=E2=80=99s an interesting id= ea, and we=E2=80=99ll explore it, though it looks like it may have some int= eresting implications that push it to future scope.=C2=A0 It feels like a n= ice-to-have.
>
> Thanks all.
>
> --Larry Garfield

This morning, while thinking about "new Pattern($pattern)," it occurred to me: why not create an OOP extension of patterns? It
wouldn't need an RFC or language changes and would allow the
development of patterns to the point where adding it to the core
language may be a no-brainer. You (and other users of it) would have a
pretty good idea of which patterns are actually important and useful
due to actually using them.

It's probably the "long way around" but at that point, you= 9;d basically
just be pulling in the extension and discussing syntax as the behavior
would be well-defined and battle-tested.

Robert Landers
Software Engineer
Utrecht NL

Are you referring to "n= ew Pattern($pattern)" specifically for regexes (similar to JS), or pat= tern matching in general? Is this also pointing at putting the behavior of = pattern matching in an object that effectively executes the pseudo code fro= m the examples, with the actual pattern matching being a syntactic sugar to= be added at a later stage?
--00000000000066c510061bb33ed1--