[swift-evolution] [SHORT Review] SE-0132: Rationalizing Sequence end-operation names

Daniel Duan daniel at duan.org
Tue Jul 26 02:01:13 CDT 2016


> On Jul 25, 2016, at 11:32 PM, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> 
> On 26 Jul 2016, at 06:50, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>>    surface area and leverages the user's understanding of how ranges
>>    work.
>> 
>>    It also implies we can replace
>> 
>>      x.removingPrefix(n)
>>      x.removingSuffix(n)
>> 
>>    with
>> 
>>      x[$+n..<]
>>      x[..<$-n]
>> 
>>   for Collections.
>> 
>> I'm not enamored of this suggestion. It succeeds in reducing API surface area, but at a severe cost to readability. You'd replace an unambiguous phrase (removing prefix or suffix), the meaning of which is further clarified by the consistent usage proposed in SE-0132, with a wordless spelling using some combination of [$+.<]. Cognitively, also, it substantially increases the burden for the reader: it replaces a single argument with a nested series of arguments; first, one must understand the meaning of the $ placeholder, then one must consider an addition or subtraction operation, then the formation of a range, and in the last example, the use of that range as a subscript argument--again, all wordlessly. Finally, subscripts have so far not been "forgiving," while today's `dropLast` very much is; this suggestion would add inconsistency by using a subscript for a forgiving or "lenient" operation.
> 
> I second Xiaodi. I am against the slicing subscripts and the ones above look even more unreadable and inscrutable than those in the proposal. I don't understand the rational.

The inspiration is D: https://dlang.org/d-array-article.html <https://dlang.org/d-array-article.html>

> _______________________________________________
> 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/ab89f45b/attachment.html>


More information about the swift-evolution mailing list