[swift-evolution] [SHORT Review] SE-0132: Rationalizing Sequence end-operation names
Nevin Brackett-Rozinsky
nevin.brackettrozinsky at gmail.com
Tue Jul 26 18:27:33 CDT 2016
On Tue, Jul 26, 2016 at 6:58 PM, Boris Wang <kona.ming at gmail.com> wrote:
> the single word “first” only means one element,
> but “prefix” can means multiple element.
>
I dispute the former claim. As evidence I cite:
• The first four letters of the alphabet are A, B, C, and D.
• The first three Presidents of the United States were George Washington,
John Adams, and Thomas Jefferson.
• The first two humans to walk on the moon were Neil Armstrong and Buzz
Aldrin.
The defense rests.
Nevin
>
> Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>于2016年7月27日
> 周三03:46写道:
>
>> > On Jul 26, 2016, at 8:30 AM, Nevin Brackett-Rozinsky <
>> nevin.brackettrozinsky at gmail.com> 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
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160726/3e7e6302/attachment.html>
More information about the swift-evolution
mailing list