> On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky 
> <[email protected]> wrote:
> 
> However, I believe that `first(n)` and `last(n)` read more clearly at the 
> point of use than `prefix(n)` and `suffix(n)`.

I've seen this a couple of times. It's something I bring up in "Other 
alternatives":

> * We considered using `first` and `last` as the basis for both 
>   single-element and multiple-element operations (such that `prefix(3)` 
>   would become `first(3)`, etc.), but:
>   
>   1. These seemed like distinct functionalities, particularly since 
>      their types are different.
>   
>   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.
>   
>   3. Most APIs work fine, but `hasFirst(_:)` is atrocious, and we see 
>      no better alternative which includes the word `first`.

To give you an idea of what I mean by #3:

        if numbers.hasFirst([1, 2, 3, 4, 5]) && numbers.hasLast([5, 4, 3, 2, 
1]) { … }

Keeping those issues in mind, do you still prefer `first(n)` over `prefix(n)`?

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to