> On 07.04.24 16:35, Larry Garfield wrote: > > 1. Should this work on arrays or iterables? This is a long standing > > limitation of PHP. The array operations don't work on iterables, even > > though we've had iterables for 20 years.) > > In the longer term, it definitely makes sense to create a separate API > here that can handle not only arrays, but iterables in general. I have > heard this suggestion in various places (including in the mailing list) > and had also looked into it in the process of this RFC, but did not > pursue it further after the initial idea, as it would be important for > me that such an API is planned accordingly and has an appropriate > repertoire right from the start (functions such as map, filter, find, > push, pop, …). In my opinion, a single function would be very out of > place, especially if this API is then really soon tackled and then > possibly differs from the implementation of the RFC.
I think it's fine to have an array-specific variant in this case, because arrays never have duplicate keys. Iterables can, and that may factor into design. Additionally, arrays are not consumed by iterating on them, but iterables may, and this could be a gotcha. I think it's fine to have an array-specific version (simpler, nicer).