<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 28 May 2016, at 20:16, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">I couldn't disagree more. Generic programming is a far more advanced concept than arrays and dictionaries, and learners should be able to use them without contending with angle brackets they don't understand.<br class=""><br class="">Fundamentally, even for an experienced user of the language, working with Collections and Sequences requires more consideration than working with arrays. It's not just a matter of how these things are spelled. It seems like you want to punish users who don't have the time or inclination to genericize their algorithms by making them write more, in the hopes that if you make working with arrays difficult enough, people will switch to generic containers. That's bonkers.<br class=""></div></blockquote><div><br class=""></div><div>It’s not about making working with arrays difficult, but if we can make working with basic generic collections/sequences just as easy, then it makes sense to encourage their use as much as possible. Like in the example below, Sequence.of&lt;Foo&gt; is pretty straightforward, and far more flexible and useful than just using [Foo], as you can trivially change the type of collection you use later.</div><div><br class=""></div><div>More complex generics definitely need to be explored separately, but Sequence.of&lt;Foo&gt; should be just as simple to use as [Foo], it’s just a little longer because of the ability to distinguish between sequence and collection.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Sat, May 28, 2016 at 14:38 Haravikk via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><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=""><br class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On 27 May 2016, at 15:31, plx via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div style="word-wrap:break-word" class=""><div class=""><br class=""></div></div></div></blockquote><blockquote type="cite" class=""><div style="word-wrap:break-word" class=""><div class="">&nbsp; protocol Sequence {</div></div></blockquote></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class=""><div class="">&nbsp; &nbsp; typealias of&lt;E&gt; == S: Self where S.Iterator.Element == E</div><div class="">&nbsp; }</div><div class=""><br class=""></div></div></blockquote></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class=""><div class="">&nbsp; // sequence-accepting variant</div><div class="">&nbsp; func doSomething&lt;S:Sequence.of&lt;Foo&gt;&gt;(values: S) { … }</div></div></blockquote></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class=""></div></blockquote><br class=""></div><div class="">This is a nice alternative; would it actually need to be declared in the angle brackets? Could it be done as:</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">        </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)" class="">func</span><span style="font-family:Menlo;font-size:11px" class="">&nbsp;doSomething(values:</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)" class="">Sequence</span><span style="font-family:Menlo;font-size:11px" class="">.</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)" class="">of</span><span style="font-family:Menlo;font-size:11px" class="">&lt;</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)" class="">Foo</span><span style="font-family:Menlo;font-size:11px" class="">&gt;) { … }</span></div><div class=""><br class=""></div><div class="">As long as it would work the same as a generic declaration this could be a good way to do it, either that or a SequenceOf type alias as mentioned.</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Still, I kind of feel like we need to do something with the array type shorthand, but I wonder if perhaps we could just get rid of it altogether, to prevent its use entirely? i.e- all instances of [Foo] can be replaced with Array&lt;Foo&gt;, but we would encourage the use of Sequence.of/SequenceOf/Collection.of/CollectionOf first wherever possible.</div><div class=""><br class=""></div><div class="">As more types become available that are ArrayLiteralConvertible it seems like we should discourage restriction of a parameter to Array except when a developer explicitly chooses it. This problem will come up with the Dictionary type shorthand as well if Swift gets some kind of Map protocol to abstract it, and we don’t even have a Set-specific syntax so it seems like it may be fairer to remove these shorthands.</div></div></blockquote></div></div></blockquote></div></body></html>