Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Robert Landers
On Sat, Jun 22, 2024 at 11:57 PM Robert Landers wrote: > > On Sat, Jun 22, 2024 at 10:53 PM Rowan Tommins [IMSoP] > wrote: > > > > On 22/06/2024 19:34, Robert Landers wrote: > > > > I've brought this up before, but I mostly see "as" being useful for > > static analysis. That's what I've mostly us

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Robert Landers
On Sat, Jun 22, 2024 at 10:53 PM Rowan Tommins [IMSoP] wrote: > > On 22/06/2024 19:34, Robert Landers wrote: > > I've brought this up before, but I mostly see "as" being useful for > static analysis. That's what I've mostly used it for C#, anyway. > Logically, you know the type, but due to one-thi

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Rowan Tommins [IMSoP]
On 22/06/2024 21:15, Robert Landers wrote: To me, that sounds kinda silly. PHP does reference counting and while there is an overhead, it doesn't prevent us from using it... The reference count is a single pre-allocated integer on the C struct holding the value; and even then, a lot of effort

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Robert Landers
On Sat, Jun 22, 2024 at 8:59 PM Arnaud Le Blanc wrote: > > On Fri, Jun 21, 2024 at 7:20 PM Robert Landers > wrote: > > > > I'm always surprised why arrays can't keep track of their internal > > > > types. Every time an item is added to the map, just chuck in the type > > > > and a count, then if

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Mark Trapp
On Sat, Jun 22, 2024 at 10:16 AM Brandon Jackson wrote: > > > 8. Capturing values out of a pattern and binding them to variables if > > > matched > > > Ok I think that's stepping a bit far out of scope. Maybe `is` should > > > simply check and not have any side effects. > > > > As above, this is

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Rowan Tommins [IMSoP]
On 22/06/2024 19:34, Robert Landers wrote: I've brought this up before, but I mostly see "as" being useful for static analysis. That's what I've mostly used it for C#, anyway. Logically, you know the type, but due to one-thing-or-another you can't "prove" the type is that type (such as foreach-ar

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Arnaud Le Blanc
On Fri, Jun 21, 2024 at 7:20 PM Robert Landers wrote: > > > I'm always surprised why arrays can't keep track of their internal > > > types. Every time an item is added to the map, just chuck in the type > > > and a count, then if it is removed, decrement the counter, and if > > > zero, remove the

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Robert Landers
On Sat, Jun 22, 2024 at 8:34 PM Robert Landers wrote: > > On Sat, Jun 22, 2024 at 8:04 PM Rowan Tommins [IMSoP] > wrote: > > > > On 21/06/2024 19:29, Larry Garfield wrote: > > > > Valid points. The line between validation and casting is a bit squishy, > > as some casts can be forced (eg, string

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Robert Landers
On Sat, Jun 22, 2024 at 8:04 PM Rowan Tommins [IMSoP] wrote: > > On 21/06/2024 19:29, Larry Garfield wrote: > > Valid points. The line between validation and casting is a bit squishy, > as some casts can be forced (eg, string to int gives 0 sometimes), and > others just cannot (casting to an obj

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Brandon Jackson
On Fri, Jun 21, 2024 at 1:22 PM Larry Garfield wrote: > > To give more context, as noted, this is a stepping stone toward ADTs. > Anything 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 includes the

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Rowan Tommins [IMSoP]
On 21/06/2024 19:03, Larry Garfield wrote: * Regex pattern This one is interesting as well ... but I would expect native regex syntax first before introducing it as part of a different RFC. Similar as generics. Named capture groups are already part of regex syntax, just not often used. The ex

Re: [PHP-DEV] [Early Feedback] Pattern matching

2024-06-22 Thread Rowan Tommins [IMSoP]
On 21/06/2024 19:29, Larry Garfield wrote: Valid points. The line between validation and casting is a bit squishy, as some casts can be forced (eg, string to int gives 0 sometimes), and others just cannot (casting to an object). So would $a as array<~int> be casting, validating, or both? I