IterableFactory pseudo type

From: Date: Thu, 10 Jan 2019 05:10:44 +0000
Subject: IterableFactory pseudo type
Groups: php.internals 
Request: Send a blank email to internals+get-103708@lists.php.net to get a copy of this message
Hello everybody and happy new year I was thinking to RFC the following union: ``` typedef IterableFactory = array | IteratorAggregate; ``` As you know, passing Iterators around is a bad idea because one can accidentally end up using them concurrently. For example if one entity is traversing the iterator, and a second entity calls rewind() and fully traverses the very same iterator, the first entity would try to continue the traversal from a finished iterator. So in order to avoid this kind of confusing designs we generally keep iterators as confined as possible - instead, we pass around "iterator factories" such as IteratorAggregate. However, that doesn't include arrays, which can be safely iterated concurrently as well. Hence my proposal. Essentially this is like Iterable but excludes Iterator. Thoughts? TY

« previous php.internals (#103708) next »