<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 10:15 AM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 16, 2015 at 7:10 AM, Donnacha Oisín Kidney <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Now that I think about it, of course <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfZeroOrOne</span> would (or <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">Optional</span>) have a random access index. I’ll update the proposal to include that.<br class=""><div class=""><br class=""></div><div class="">I really like the <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfZeroOrOne</span> solution. The semantics and types certainly make more sense. I’m not sure that it reduces the amount of code, though: the three extensions are still needed, plus an extra struct. (I suppose that’s not counting the extra version of <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">LazyFilterCollection</span>. Am I right in saying that that is intended to be added?)</div></div></blockquote></div></div></div></div></blockquote><div><br class=""></div>I'm not sure I understand why we need another version of LazyFilterCollection. Can you explain?</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Here’s what I have for the collection (I tried to mimic the standard library’s <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfOne</span>):</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">public</span> <span style="color:#bb2ca2" class="">struct</span> CollectionOfZeroOrOne<Element> : <span style="color:#703daa" class="">CollectionType</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><font class="">[...]</font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div><div class=""><br class=""></div><div class="">Does that seem reasonable?</div></div></blockquote><div class=""><br class=""></div><div class="">It looks reasonable, but I don't understand why adding CollectionOfZeroOrOne improves the API. Dave?</div></div></div></div></div></blockquote><div><br class=""></div>It doesn't. I think it improves code reuse, and gives people an adapter to use when they want to pass an Optional where a Collection or Sequence is required.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Dmitri</div><div class=""> </div></div>-- <br class=""><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank" class="">gribozavr@gmail.com</a>>*/</div>
</div></div>
</div></blockquote></div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">
</div>
<br class=""></body></html>