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....@gmail.com>:
>
> On Thu, Jun 20, 2019 at 1:45 AM Wes <netmo....@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to