On 1 Mar 2025, at 08:37, Rob Landers <rob@bottled.codes> wrote: > > Hi Alwin, > > You may be interested in http://wiki.php.net/rfc/records, whose goal from the > beginning was a new type that behaved like arrays (value semantics, copy on > write) as well as the ability to attach behavior to them. > > I’ve since abandoned it due to the poor reception it got on the list and > decided to pursue inner classes instead. However, I spent nearly a year > thinking through that RFC, so feel free to pick my brain via email, or a > call. > > The first implementation didn’t use classes at all, instead were implemented > on arrays and enforced an array shape. This meant that records were a subtype > of arrays (so you could pass a record as an argument in lieu of an array). > This worked pretty well, but feedback I got from colleagues challenged me to > add the ability for behavior. So, I had to abandon that implementation. So, > if you look at that RFC and remove all the behavior, you’re basically left > with a record keyword and the ability to specify types and props. > > The biggest challenges with that implementation (and array shapes in > general), happen to be around WHEN to do type checking and how to get a > handle on references. Further, there’s quite a few parts of php that reach > into the implementation of arrays and do something different than the > canonical implementation (opcache, is a good example here) that can end up > breaking things in fun ways. Particularly if you somehow end up with one of > these in one of the magic global arrays. > > Anyway, best of luck to you and don’t hesitate to reach out! > > — Rob
Hey Rob, I did stumble upon your Records RFC at some point, but I felt it tries to solve a different problem, because it provides a nominal interface rather than a structural interface like I have in mind, never mind behavior. But thanks either way for offering your help! I might contact you just to ask some things about the internals of PHP, mostly out of curiosity. :-) Alwin