[swift-evolution] [Draft] Rationalizing Sequence end-operation names

L. Mihalkovic laurent.mihalkovic at gmail.com
Wed Jun 29 02:25:43 CDT 2016


@brent: i noticed that you have the habit of redacting out the name of the people from your replies. Considering you seem to be the only one, and how much clarity it removes from the dialog, do you think you could perhaps reconsider?
Regards
LM
(From mobile)

On Jun 29, 2016, at 12:40 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:

>> I was in the midst of writing a reply along the same lines, so I figured I'd add to David's reply here. There are two characteristics I would expect from a method named "prefix" or "suffix".
>> 
>> First, it should return a subsequence containing zero to count elements. (By contrast, something named "first" should return nil or one element, but certainly no more.)
>> 
>> Second, in the case of "prefix", the first element of the subsequence (if any) should be the first element of the sequence; in the case of "suffix", the last element of the subsequence (if any) should be the last element of the sequence.
> 
> I would phrase these things slightly differently. In my thinking, a method with `prefix` or `suffix` in its name:
> 
>    1. Operates on a subsequence at the beginning/end of the sequence,
> 
>    2. Measured *relative* to the beginning/end.
> 
> An index-based operation doesn't fit this definition because an index is not *relative* to anything—it's an *absolute* position within the sequence.
> 
> Put another way, in my view, "prefix" and "suffix" don't merely mean "anchored at the beginning/end". A prefix or suffix is attached to a "middle". There is no middle in the index-based operations.
> 
> It is, of course, very possible to use methods to express what the index-based operations do:
> 
>    friends.upTo(i)
>    friends.through(i)
>    friends.from(i)
> 
> But at this point, we've basically arrived at `friends[to: i]` etc.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list