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

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

Reply via email to