<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 26, 2016 at 6:58 PM, Boris Wang <span dir="ltr"><<a href="mailto:kona.ming@gmail.com" target="_blank">kona.ming@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="white-space:pre-wrap">the single word “first” only means one element,<br>but “prefix” can means multiple element.<br></div></blockquote><div><br></div><div>I dispute the former claim. As evidence I cite:</div><div><br></div><div>• The first four letters of the alphabet are A, B, C, and D.</div><div>• The first three Presidents of the United States were George Washington, John Adams, and Thomas Jefferson.</div><div>• The first two humans to walk on the moon were Neil Armstrong and Buzz Aldrin.</div><div><br></div><div>The defense rests.</div><div><br></div><div>Nevin</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="white-space:pre-wrap"></div><br><div class="gmail_quote"><div dir="ltr">Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>>于2016年7月27日 周三03:46写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">> On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky <<a href="mailto:nevin.brackettrozinsky@gmail.com" target="_blank">nevin.brackettrozinsky@gmail.com</a>> wrote:<br>
><br>
> However, I believe that `first(n)` and `last(n)` read more clearly at the point of use than `prefix(n)` and `suffix(n)`.<br>
<br>
I've seen this a couple of times. It's something I bring up in "Other alternatives":<br>
<br>
> * We considered using `first` and `last` as the basis for both<br>
> single-element and multiple-element operations (such that `prefix(3)`<br>
> would become `first(3)`, etc.), but:<br>
><br>
> 1. These seemed like distinct functionalities, particularly since<br>
> their types are different.<br>
><br>
> 2. We're not comfortable with heavily overloading a property with a<br>
> bunch of methods, and didn't want to make `first` and `last` into<br>
> methods.<br>
><br>
> 3. Most APIs work fine, but `hasFirst(_:)` is atrocious, and we see<br>
> no better alternative which includes the word `first`.<br>
<br>
To give you an idea of what I mean by #3:<br>
<br>
if numbers.hasFirst([1, 2, 3, 4, 5]) && numbers.hasLast([5, 4, 3, 2, 1]) { … }<br>
<br>
Keeping those issues in mind, do you still prefer `first(n)` over `prefix(n)`?<br>
<br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br></div></div><span class="">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</span></blockquote></div>
</blockquote></div><br></div></div>