Re: [RFC] Normalize array's "auto-increment" value on copy on write
| From: | Niklas Keller | Date: | Thu, 20 Jun 2019 10:25:45 +0000 |
| Subject: | Re: [RFC] Normalize array's "auto-increment" value on copy on write | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105995@lists.php.net to get a copy of this message | ||
Hi Wes,
I don't think it'll work the way you described. I think we have to
make the auto-increment value be entirely dependent on the values in
the array for it to work.
Consider the following example combining your initial assertion in the
RFC with an example further down:
```
<?php
$array = [0, 1, 2, 3];
unset($array[3], $array[2]);
$arrayCopy = $array;
assert($array === $arrayCopy);
$arrayCopy[] = 2;
assert($arrayCopy === [0, 1, 2]); // this assertion must pass; it
doesn't currently
$array[] = 2;
assert($array === $arrayCopy); // still identical/equal
```
https://3v4l.org/vDj4c
In that case
$array isn't reset by COW because it's not copied and
the initial assertion doesn't pass anymore.
Regards, Niklas
Am Do., 20. Juni 2019 um 09:36 Uhr schrieb Nikita Popov <nikita.ppv@gmail.com>:
>
> On Thu, Jun 20, 2019 at 1:45 AM Wes <netmo.php@gmail.com> wrote:
>
> > Hello internals, I just published another RFC
> >
> >
> > https://wiki.php.net/rfc/normalize-array-auto-increment-on-copy-on-write
> >
> > Please keep in mind that my intentions are good and I am proposing things
> > in the interest of everybody. Also, I am aware that I might be wrong. If I
> > am, please illustrate the reason without barking at me. Thanks <3
> >
>
> Looks reasonable to me.
>
> Nikita