[swift-dev] [swift-corelibs-dev] LazySequenceType: make prefix return a lazy collection

Dmitri Gribenko gribozavr at gmail.com
Sat Feb 13 23:52:40 CST 2016

On Mon, Jan 4, 2016 at 2:21 PM, Tony Parker via swift-dev <
swift-dev at swift.org> wrote:

> Hi Mark,
> I’m going to loop in the swift-dev list for this question.

Thanks, Tony!

> On Jan 4, 2016, at 5:15 AM, Mark Aron Szulyovszky via swift-corelibs-dev <
> swift-corelibs-dev at swift.org> wrote:
> Hi,
> I came across hit issue while chaining filter() and prefix() on lazy
> sequences:
> https://bugs.swift.org/browse/SR-461
> And started wondering if it would be more consistent if
> lazy.filter().prefix() returned a custom
> LazySequenceType<Generator.Element> instead of
> Slice<LazyFilterCollection<Range<Generator.Element>>>.
> That way lazy.filter().prefix() could be used to chain *pure lazy
> operations*, which can be actually quite useful in some cases.
Hi Mark,

I think this would make a lot of sense, since the lazy implementation of
prefix() would allow the operation to be performed in O(1) instead of
triggering the whole calculation chain.  But for random-access collections,
keeping the current implementation would be best, I think.  Would you mind
sending a quick summary of the proposed new API to swift-evolution?  That
mailing list is the preferred place for such discussions.  You can read
more about it here:

The ambiguity issue that you are seeing, I think, should be viewed as a
type checker issue and should be solved separately.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160213/6cd23c41/attachment.html>

More information about the swift-dev mailing list