Re: [VOTE] ImmutableIterable (immutable, rewindable, allows any key&repeating keys)

From: Date: Wed, 16 Jun 2021 13:57:47 +0000
Subject: Re: [VOTE] ImmutableIterable (immutable, rewindable, allows any key&repeating keys)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114906@lists.php.net to get a copy of this message
Hi Nikita,

> 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.

It may be more positive, 
but I don't think it'd pass with any name or by changing the constructor to fromIterable.
Over half of the objections are to functionality, over half to unspecified reasons,
and other email discussion responses don't seem to indicate interest in having the
functionality, just on clarifying implementation or naming details

I was trying to avoid proposing functionality similar to that already in php-ds or an improvement to
spl
(especially with ongoing namespacing policy discussion),
but that seems to be a mistake - if it was chosen for inclusion in those modules then it'd be a
very common use case
(e.g. https://www.php.net/manual/en/splqueue.construct,
https://www.php.net/manual/en/class.ds-map.php, etc)

Cheers,
Tyson


Thread (10 messages)

« previous php.internals (#114906) next »