On 17 August 2026 23:34:07 BST, "سپهر محمودی" <[email protected]> wrote:
>However, I’d like to point out that such a feature is a very large
>
>undertaking. It would require:
>
>   - A new ArraySlice type in the Zend Engine
>   - Changes to memory management and reference counting
>   - Updating potentially hundreds of array functions to accept it
>   - A major RFC with significant design discussion

Hi Sepehr,

As I said on the previous thread (I'm not sure why you started a new one), I 
don't think it's that big a task.

- It doesn't need to be a new base type, just a new internal class.
- We don't have to update every function at once, because a function expecting 
"array" will naturally reject "ArraySlice" until we change something.
- The internal mechanism would either be an implementation of the existing 
Iterator mechanism, or something very similar.

In fact, the simplest starting point would be no functions at all, just an 
optimised ArraySliceIterator. The actual search part is fairly easy to write in 
user code.

Then in a separate RFC, add a new set of functions like "iter_search", 
"iter_any", etc, which would be useful with *any* iterator, not just this 
specific one.

And possibly a third RFC to add special syntax for creating an 
ArraySliceIterator, similar to how it looks in Python or Swift.

That way, each small step is useful in itself, but building towards something 
very general, rather than only solving one narrow use case.

Regards,

Rowan Tommins
[IMSoP]

Reply via email to