[swift-evolution] [Pitch] Remove destructive consumption from Sequence
dabrahams at apple.com
Thu Jun 30 17:37:16 CDT 2016
on Thu Jun 30 2016, Russ Bishop <xenadu-AT-gmail.com> wrote:
>> On Jun 30, 2016, at 10:26 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> It would
>> be very interesting to know about any real-world models of single-pass
>> sequences that people are using in Swift, since we don't supply any in
>> the standard library.
> I already gave an example of this earlier in the thread:
Yes, I remember that one. It's not that I believe these things don't
exist at all; I'm trying to get a read on how important it is that they
fit into the standard library's protocol framework. For that, I need to
know if they are very common.
>>> I use it in a LazyRowSequence<T: SqlModelConvertible> where
>>> querying Sqlite in WAL mode allows multiple concurrent readers to
>>> get point-in-time snapshots of the database. The query can’t be
>>> replayed without buffering all the rows in memory because Sqlite’s
>>> step functions are not bi-directional. In some cases we are talking
>>> about tens of thousands of rows (or even hundreds of thousands) and
>>> the ability to avoid buffering them is a feature, not a bug.
> IMHO the typical case for single-pass is IO.
Yes. Also, truly-random number generators.
> In this case it would work just as well as LazyRowIterator<T> assuming
> the language allows for-in on an iterator.
So, you're not interested in using algorithms like map and filter on
If it was just about for-in, we could say you can for-in over any
More information about the swift-evolution