<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Mark,<div class=""><br class=""></div><div class="">I’m going to loop in the swift-dev list for this question.</div><div class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 4, 2016, at 5:15 AM, Mark Aron Szulyovszky via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><div class=""><div dir="ltr" class=""></div></div></div>
<div class=""><br class=""></div><div class="">I came across hit issue while chaining filter() and prefix() on lazy sequences:</div><div class=""><a href="https://bugs.swift.org/browse/SR-461" target="_blank" class="">https://bugs.swift.org/browse/SR-461</a><br class=""></div><div class=""><br class=""></div><div class="">And started wondering if it would be more consistent if lazy.filter().prefix() returned a custom LazySequenceType&lt;Generator.Element&gt; instead of Slice&lt;LazyFilterCollection&lt;Range&lt;Generator.Element&gt;&gt;&gt;.</div><div class=""><br class=""></div><div class="">That way lazy.filter().prefix() could be used to chain <b class="">pure lazy operations</b>, which can be actually quite useful in some cases.</div><div class=""><br class=""></div><div class="">I understand that this has implications, and it would make prefix() less consistent in terms of return type, but it would eliminate confusion like&nbsp;<a href="https://bugs.swift.org/browse/SR-461" target="_blank" class="">SR-461</a>.</div><div class="">Also, this wouldn't be a much different than how how lazy.filter() is implemented, since it also returns a custom LazySequenceType instead of SequenceType.</div><div class=""><br class=""></div><div class="">Has this been considered before? Would there be any cases where this would create unintended side effects?</div><div class="">As far as I see, it wouldn't change the meaning of prefix(), only would it extend its usefulness.&nbsp;</div><div class=""><br class=""></div><div class="">I submitted a PR to the SwiftSequence library that demonstrates the implementation of this:&nbsp;<a href="https://github.com/itchingpixels/SwiftSequence/commit/26101e5aec6c266048bbad4db7b44b9c453f07ca" target="_blank" class="">https://github.com/itchingpixels/SwiftSequence/commit/26101e5aec6c266048bbad4db7b44b9c453f07ca</a></div><div class=""><br class=""></div><div class="">And I'm happy to contribute to contribute it to stdlib if people find it useful.</div><div class=""><br class=""></div><div class="">Thanks a lot!</div><div class=""><br class=""></div><div class="">Mark</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=U7z7oSqRMSwdl2rYt9JJ4zIFaeg4R-2FxExg9xndDuCbzcb719IErFwE9oUcCs9n1w6gQ9-2Bp0kxsflk5w-2BWhOMfXpz9XepU5l3Ws2hb-2B1IzgqGcreCFNBoJ-2Fs6ixyT-2FLRtLDcMUSrDPcEW0udABC0BaJf3pm-2BNLyjIvMEeOYl1HGsP9YUZDrcmnL5yFIGcCbPS6bTKGvG-2BY7YcIVW9b6sOiNCZgSmHS6nDv-2BLTlqqSagM-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></div></body></html>