Re: [PHP-DEV] [RFC] Typed array declarations
[email protected] (MichaĆ Marcin Brzuchalski) Tue, 21 Jul 2026 14:03:34 +0200
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CABdc3WqzOq_WOQD8ToJysCjqycDiXdY4w4TGS5WOjqsY2E2vUg@mail.gmail.com> |
--000000000000a19f6706571dd0ac Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pon., 20 lip 2026 o 13:48 Wendell Adriel <[email protected]> napisa=C5=82(a): > 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 refineme= nt >> 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 durin= g >> the design of Level 3, or whether this class of internal APIs simply has= n'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() mu= st >> always hold), > > BTW, on this, is this already an RFC, or is the implementation somewhere > I can take a look at? > I actually moved away from the direction I originally suggested (adding element constraints to arrays). I'm now exploring a separate approach based on dedicated immutable value types, but it's still too early to discuss as a concrete proposal. I'd rather wait until the design has stabilized. Cheers, Micha=C5=82 Marcin Brzuchalski --000000000000a19f6706571dd0ac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g= mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">pon., 20 lip 20= 26 o 13:48=C2=A0Wendell Adriel <<a href=3D"mailto:wendelladriel.ti@gmail= .com">[email protected]</a>> napisa=C5=82(a):<br></div><blockqu= ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px= solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"= ><div><div style=3D"font-size:small"><div style=3D"font-family:arial,sans-s= erif;color:rgb(0,0,0)">Hey=C2=A0<span style=3D"font-family:Arial,Helvetica,= sans-serif;background-color:transparent;color:rgb(34,34,34)">Micha=C5=82,</= span></div><span><div style=3D"font-family:arial,sans-serif;color:rgb(0,0,0= )"><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;= border-left:1px solid rgb(204,204,204);padding-left:1ex">This raises a broa= der architectural question:</blockquote><blockquote class=3D"gmail_quote" s= tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad= ding-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-lef= t:1ex">Should Level 3 typed arrays rely on function-specific guards for the= se APIs, or should internal APIs gradually move towards a model where the r= esult is built in a temporary zval and only assigned through a single typed= assignment after construction?</blockquote><blockquote class=3D"gmail_quot= e" 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 approach would naturally preserve atomicity and would work = not only for list, but also for future typed arrays.</blockquote><blockquot= e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s= olid 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 rg= b(204,204,204);padding-left:1ex">I'm not claiming this makes Level 3 im= possible. Quite the opposite - I think it highlights an implementation issu= e that any persistent refinement over mutable arrays will eventually have t= o solve, regardless of whether the refinement is list, array<T>, or s= omething else.</blockquote><blockquote class=3D"gmail_quote" style=3D"margi= n: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 0p= x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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.=C2=A0</blockquote></div></span></div></div><div><br></= div><div><div style=3D"font-family:arial,sans-serif;font-size:small;color:r= gb(0,0,0)">This is very interesting.</div><div style=3D"font-family:arial,s= ans-serif;font-size:small;color:rgb(0,0,0)">I thought about it, but didn= 9;t dive too much into it.</div><div style=3D"font-family:arial,sans-serif;= font-size:small;color:rgb(0,0,0)"><br></div><div style=3D"font-family:arial= ,sans-serif;font-size:small;color:rgb(0,0,0)">However, from some checks I&#= 39;ve done myself, when you say: "<span style=3D"font-family:Arial,Hel= vetica,sans-serif;background-color:transparent;color:rgb(34,34,34)">or shou= ld internal APIs gradually move towards a model where the result is built i= n a temporary zval and only assigned through a single typed assignment afte= r construction?"</span></div><div style=3D"font-family:arial,sans-seri= f;font-size:small;color:rgb(0,0,0)"></div><div style=3D"font-family:arial,s= ans-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 style=3D"font-family:ar= ial,sans-serif;font-size:small;color:rgb(0,0,0)">If this is something that = people would agree to follow, I think it would be great.</div><br></div><di= v><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2= 04,204,204);padding-left:1ex" class=3D"gmail_quote">I've been implement= ing a prototype of persistent list-typed properties (where list is a struct= ural refinement of array, i.e. array_is_list() must always hold),<span clas= s=3D"gmail_default" style=3D"font-family:arial,sans-serif;font-size:small;c= olor:rgb(0,0,0)"></span></blockquote><div style=3D"font-family:arial,sans-s= erif;font-size:small;color:rgb(0,0,0)"></div><div style=3D"font-family:aria= l,sans-serif;font-size:small;color:rgb(0,0,0)"><span style=3D"border-style:= none;background:none">BTW, on this</span>, is this already an RFC, or is th= e implementation somewhere I can take a look at?</div></div></div></div></b= lockquote><div><br></div><div>I actually moved away from the direction I or= iginally suggested (adding element constraints to arrays). I'm now expl= oring a separate approach based on dedicated immutable value types, but it&= #39;s still too early to discuss as a concrete proposal. I'd rather wai= t until the design has stabilized.</div><div><br></div><div>Cheers,</div><d= iv>Micha=C5=82 Marcin Brzuchalski</div></div></div> --000000000000a19f6706571dd0ac--