<div dir="ltr">Whoops, hit reply too soon. Please consider the following inserted in the gap in my last email:<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">2. We're not comfortable with heavily overloading a property with a bunch of methods, and didn't want to make `first` and `last` into methods.</blockquote><div><br></div><div>I am okay with this overload precisely *because* the functionality is so similar.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">3. Most APIs work fine, but `hasFirst(_:)` is atrocious, and we see </span><span style="font-size:12.8px">no better alternative which includes the word `first`.</span></blockquote><div><br></div><div>Agreed. Both `starts(with:)` or `hasPrefix(_:)` are much better, and I would be happy with either.</div><div><br></div><div><br></div><div>…and I seem to have cut off a sentence at the end of my last email:</div><div><br></div><div><span style="font-size:12.8px">Something like `prefix(limit: n)` is more descriptive than the bare `prefix(n)` form, however in my view it still falls short of clarity achieved by `first(n)`.</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Nevin</span></div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 26, 2016 at 7:16 PM, Nevin Brackett-Rozinsky <span dir="ltr"><<a href="mailto:nevin.brackettrozinsky@gmail.com" target="_blank">nevin.brackettrozinsky@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 dir="ltr"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">* 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></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> 1. These seemed like distinct functionalities, particularly since<br> their types are different.</blockquote><div><br></div></span><div>I think the functionality of “Please give me the first 1 element” is extremely similar to “Please give me the first n elements”.</div><span class=""><div><br></div><div> </div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Keeping those issues in mind, do you still prefer `first(n)` over `prefix(n)`?</blockquote><div class="gmail_extra"><br></div></span><div class="gmail_extra">In my subjective opinion, `.first`, `.first(n)`, and `starts(with: [1, 2, 3])` are crystal-clear at the use site, and coexist just fine. Additionally, `hasPrefix([1, 2, 3])` is equally clear and I would be fine with that—in particular I am fine with the “get” and “test” methods using different words.</div><div class="gmail_extra"><br></div><div class="gmail_extra">By contrast, I find `prefix(n)` to be unclear about the role of `n`. Something like `prefix(limit: n)` </div><div><div class="h5"><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 26, 2016 at 3:46 PM, Brent Royal-Gordon <span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span>> 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>
</span>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>
<span><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
</font></span></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>