On Tue, Jun 15, 2021 at 4:01 PM tyson andre <tysonandre...@hotmail.com>
wrote:

> Hi internals,
>
> Voting has started on the ImmutableIterable RFC
> https://wiki.php.net/rfc/cachediterable
>
> Previous discussion can be found in https://externals.io/message/114834
>
> Recent changes:
> - The name was renamed to `ImmutableIterable` to indicate that it cannot
> be changed after being constructed.
>   It was brought up in previous discussions that the previous name of
> `CachedIterable` could easily be assumed to have functionality similar to
> on-demand iterators/iterables such as https://php.net/cachingiterator
>   (Additionally, immutability is rare among spl data structures)
> - `__set_state` was added
>

Hey Tyson,

I like the concept here. I think the naming choice is unfortunate, and
causing confusion for people.

What you're really proposing here is a data structure: A sequence of
key-value-pairs. That generally seems like a sensible thing to have, in
that we can implement it significantly more efficiently in core than you
could do it in userland, especially when it comes to memory usage.

The issue is that you're not really framing this as a data structure, but
as an iterable. I get that memoizing an iterable was the original
motivation here, but I think it causes confusion. If this were
KeyValueSequence::fromIterable($iterable), I think that the meaning and
behavior would be perfectly clear -- of course it would eagerly collect the
iterable, there is no other way it could reasonably work! I think Marco's
concerns wouldn't come up either -- it's perfectly reasonable for a data
structure to implement support for serialization and JSON encoding. Not so
much for an iterator.

Regards,
Nikita

Reply via email to