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

David Hart david at hartbit.com
Tue Jul 26 01:32:10 CDT 2016

On 26 Jul 2016, at 06:50, Xiaodi Wu via swift-evolution <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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160726/056e9748/attachment.html>

More information about the swift-evolution mailing list