[swift-evolution] [Review] SE-0122: Use colons for subscript declarations

Pyry Jahkola pyry.jahkola at iki.fi
Wed Jul 20 02:47:03 CDT 2016


> On 20 Jul 2016, Chris Lattner wrote:
> 
> The review of "SE-0122: Use colons for subscript declarations " begins now and runs through July 24. The proposal is available here:
> 
> 	https://github.com/apple/swift-evolution/blob/master/proposals/0122-use-colons-for-subscript-type-declarations.md
> 
> 	* What is your evaluation of the proposal?

I'm mildly in favour because I think (settable) subscripts are more similar to properties than functions. But is this change worth having in Swift 3? I'm a bit surprised it's discussed this late in the cycle.

Here are some considerations on the topic:

1. If we bring colons in, why not change the parentheses into brackets too? Like so:

    public subscript[index: Int]: Element

2. If we change the arrows into colons but then later choose to make throwing subscripts possible, how could that be still done? Probable answer: by adding the `throws` specifier to the getter or setter as needed.

3. Do we want to address the fact that – unlike functions – subscript arguments currently have implicitly blank external names, i.e. that `subscript(at: Int)` and `subscript(_ at: Int)` are equivalent? I don't think we do; but if that's the case then it's probably a good idea to also make the declaration syntax less alike with functions. So that would be a small argument in favour of SE-0122.

> 	* Is the problem being addressed significant enough to warrant a change to Swift?

Probably not at this stage. I think this change could be introduced even post-Swift 3, although that would then require maintaining both syntaxes for an extended period of time.

> 	* Does this proposal fit well with the feel and direction of Swift?

I think so.

> 	* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

N/A

> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

A quick reading.

— Pyry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160720/8370e1b9/attachment.html>


More information about the swift-evolution mailing list