Re: [PHP-DEV] [RFC] Typed array declarations
[email protected] (Wendell Adriel) Mon, 20 Jul 2026 12:48:07 +0100
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CA+1VZ8sxXbXTMyqQ1yUMxiocphBcosSuE+WzwUE-4033HN+wCA@mail.gmail.com> |
--0000000000008815b00657097b5c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Micha=C5=82, This raises a broader architectural question: > Should Level 3 typed arrays rely on function-specific guards for these > APIs, or should internal APIs gradually move towards a model where the > result is built in a temporary zval and only assigned through a single > typed assignment after construction? > That approach would naturally preserve atomicity and would work not only > for list, but also for future typed arrays. > I'm not claiming this makes Level 3 impossible. Quite the opposite - I > think it highlights an implementation issue that any persistent refinemen= t > over mutable arrays will eventually have to solve, regardless of whether > the refinement is list, array<T>, or something else. > I'd be interested to hear whether this has already been considered during > the design of Level 3, or whether this class of internal APIs simply hasn= 't > been explored yet. This is very interesting. I thought about it, but didn't dive too much into it. However, from some checks I've done myself, when you say: "or should internal APIs gradually move towards a model where the result is built in a temporary zval and only assigned through a single typed assignment after construction?" That going into this direction would be very beneficial, however, I think this would imply touching a lot of things that can have a broader impact. If this is something that people would agree to follow, I think it would be great. I've been implementing a prototype of persistent list-typed properties > (where list is a structural refinement of array, i.e. array_is_list() mus= t > always hold), BTW, on this, is this already an RFC, or is the implementation somewhere I can take a look at? As it was advised before, since this RFC can be affected by the generics design, for now I'll keep the RFC on hold, as well as because it's not a PHP 8.6 one, and as Larry asked, since we're close to PHP 8.6, this version should be the focus. But I'd be happy to discuss and improve the RFC along the way. *---* *Best Regards,* *Wendell Adriel.* *Software Engineer & Architect* *https://wendelladriel.com <https://wendelladriel.com>* --0000000000008815b00657097b5c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div><div class=3D"gmail_default" style= =3D"font-size:small"><div class=3D"gmail_default" style=3D"font-family:aria= l,sans-serif;color:rgb(0,0,0)">Hey=C2=A0<span style=3D"font-family:Arial,He= lvetica,sans-serif;background-color:transparent;color:rgb(34,34,34)">Micha= =C5=82,</span></div><span class=3D"gmail-im"><div class=3D"gmail_default" s= tyle=3D"font-family:arial,sans-serif;color:rgb(0,0,0)"><br><blockquote clas= s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r= gb(204,204,204);padding-left:1ex">This raises a broader architectural quest= ion:</blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px = 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></bl= ockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e= x;border-left:1px solid rgb(204,204,204);padding-left:1ex">Should Level 3 t= yped arrays rely on function-specific guards for these APIs, or should inte= rnal APIs gradually move towards a model where the result is built in a tem= porary zval and only assigned through a single typed assignment after const= ruction?</blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px = 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>= </blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px = 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">That approac= h would naturally preserve atomicity and would work not only for list, but = also for future typed arrays.</blockquote><blockquote class=3D"gmail_quote"= style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p= adding-left:1ex"><br></blockquote><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">I'm not claiming this makes Level 3 impossible. Quite the op= posite - I think it highlights an implementation issue that any persistent = refinement over mutable arrays will eventually have to solve, regardless of= whether the refinement is list, array<T>, or something else.</blockq= uote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo= rder-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote><bl= ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef= t:1px solid rgb(204,204,204);padding-left:1ex">I'd be interested to hea= r whether this has already been considered during the design of Level 3, or= whether this class of internal APIs simply hasn't been explored yet.= =C2=A0</blockquote></div></span></div></div><div><br></div><div><div class= =3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small;co= lor:rgb(0,0,0)">This is very interesting.</div><div class=3D"gmail_default"= style=3D"font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">I = thought about it, but didn't dive too much into it.</div><div class=3D"= gmail_default" style=3D"font-family:arial,sans-serif;font-size:small;color:= rgb(0,0,0)"><br></div><div class=3D"gmail_default" style=3D"font-family:ari= al,sans-serif;font-size:small;color:rgb(0,0,0)">However, from some checks I= 've done myself, when you say: "<span style=3D"font-family:Arial,H= elvetica,sans-serif;background-color:transparent;color:rgb(34,34,34)">or sh= ould internal APIs gradually move towards a model where the result is built= in a temporary zval and only assigned through a single typed assignment af= ter construction?"</span></div><div class=3D"gmail_default" style=3D"f= ont-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)"></div><div cl= ass=3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small= ;color:rgb(0,0,0)">That going into this direction would be very beneficial,= however, I think this would imply touching a lot of things that can have a= broader impact.</div><div class=3D"gmail_default" style=3D"font-family:ari= al,sans-serif;font-size:small;color:rgb(0,0,0)">If this is something that p= eople would agree to follow, I think it would be great.</div><br></div><div= ><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20= 4,204,204);padding-left:1ex" class=3D"gmail_quote">I've been implementi= ng a prototype of persistent list-typed properties (where list is a structu= ral refinement of array, i.e. array_is_list() must always hold),<span class= =3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small;co= lor:rgb(0,0,0)"></span></blockquote><div class=3D"gmail_default" style=3D"f= ont-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)"></div><div cl= ass=3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small= ;color:rgb(0,0,0)"><span aria-invalid=3D"grammar" class=3D"Lm ng" style=3D"= border-style:none;background:none">BTW, on this</span>, is this already an = RFC, or is the implementation somewhere I can take a look at?</div><div cla= ss=3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small;= color:rgb(0,0,0)"><br></div><div class=3D"gmail_default" style=3D"font-fami= ly:arial,sans-serif;font-size:small;color:rgb(0,0,0)">As it was advised bef= ore, since this RFC can be affected by the generics design, for now I'l= l keep the RFC on hold, as well as because it's not a PHP 8.6 one, and = as Larry asked, since we're close to PHP 8.6, this version should be th= e focus.</div><div class=3D"gmail_default" style=3D"font-family:arial,sans-= serif;font-size:small;color:rgb(0,0,0)">But I'd be happy to discuss and= improve the RFC along the way.</div></div><div><br></div><div><div dir=3D"= ltr" class=3D"gmail_signature"><div dir=3D"ltr"><div dir=3D"ltr"><div dir= =3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr= "><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div = dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><b><span sty= le=3D"font-family:verdana,sans-serif"><span style=3D"font-size:13.3333px">-= --</span></span></b><span style=3D"font-family:verdana,sans-serif"><span st= yle=3D"font-size:13.3333px"><br></span></span></div><div dir=3D"ltr"><b><sp= an style=3D"font-family:verdana,sans-serif"><span style=3D"font-size:13.333= 3px">Best Regards,</span></span></b><br></div><div><b><span style=3D"font-f= amily:verdana,sans-serif"><span style=3D"font-size:13.3333px">Wendell Adrie= l.</span></span></b></div><div><b style=3D"font-family:verdana,sans-serif;f= ont-size:13.3333px">Software Engineer & Architect</b><b><span style=3D"= font-family:verdana,sans-serif"><span style=3D"font-size:13.3333px"><br></s= pan></span></b></div><div><b><span style=3D"font-family:verdana,sans-serif"= ><span style=3D"font-size:13.3333px"><span style=3D"color:rgb(255,127,0)"><= a href=3D"https://wendelladriel.com" target=3D"_blank">https://wendelladrie= l.com</a></span></span></span></b></div></div></div></div></div></div></div= ></div></div></div></div></div></div></div></div></div></div></div></div> --0000000000008815b00657097b5c--