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

Vladimir.S svabox at gmail.com
Wed Jul 20 10:06:33 CDT 2016

On 20.07.2016 9:12, Dmitri Gribenko via swift-evolution wrote:
> On Tue, Jul 19, 2016 at 10:50 PM, Chris Lattner via swift-evolution
> <swift-evolution at swift.org> wrote:
>> Hello Swift community,
>> 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
> Weakly against.
> The subscript is a crossover between a function and a computed
> property, and depending how you look at it, you will find either ":"
> to be a better fit if you argue that they are closer to properties, or
> that "->" is better, if you argue that subscripts are closer to

Just want to understand this opinion. How subscript could be closer to 
function(method) than to property?
Calling subscript you don't use `()`
Subscript could be assigned to some value, just like property, method 
couldn't be.
What does `->` syntax mean for subscript setter? In all other parts of 
language `->` means 'returns', i.e. requirement to return some value. Here 
we have to read this as 'returns T but for setter it want to get T'
Setter of subscript *does not* return anything.

For me, subscript is *much* more like property with getter/setter, than 
method from any point of view(declaration or using).

> functions.  I don't find either argument to be more convincing that
> the other, so I don't see a reason to change this part of the
> language.
> I wouldn't mind if the change would be made though, but I think by
> changing subscripts to use colons we would end in the opposite, but
> totally symmetrical situation compared to what we have now.
> Dmitri

More information about the swift-evolution mailing list