[swift-evolution] Change subscripts to use colons

Xiaodi Wu xiaodi.wu at gmail.com
Mon Jul 11 00:07:15 CDT 2016


+1 as well. It always feels a little weird to be writing a setter inside
something that says it returns what should be the argument.
On Mon, Jul 11, 2016 at 00:05 Patrick Pijnappel via swift-evolution <
swift-evolution at swift.org> wrote:

> Good point. A subscript basically a parameterized property, not a
> function. I'm in favor.
>
> On Mon, Jul 11, 2016 at 9:18 AM, James Froggatt via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Currently, the signature is:
>> subscript(_ example: Int) -> Element {
>>     get { … }
>>     set { … }
>> }
>>
>> The alternative, using a colon, would be:
>> subscript(_ example: Int) : Element {
>>     get { … }
>>     set { … }
>> }
>>
>> Sorry if that wasn't clear.
>>
>> This would be to better reflect the property-like nature of access.
>>
>> From James F
>>
>> On 10 Jul 2016, at 23:57, Brent Royal-Gordon <brent at architechies.com>
>> wrote:
>>
>> >> On Jul 9, 2016, at 11:48 AM, James Froggatt via swift-evolution <
>> swift-evolution at swift.org> wrote:
>> >>
>> >> Subscripts are a hybrid of properties and functions, since they have a
>> parameter list, as well as getters and setters, so use of either symbol
>> will be unusual in this case.
>> >>
>> >> However, I think a colon is more suitable, since it implies the
>> possibility to set the value.
>> >
>> > Can you show us an example of the current syntax and your proposed
>> replacement? I'm not sure what you actually mean by "use colons".
>> >
>> > --
>> > Brent Royal-Gordon
>> > Architechies
>> >
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
> _______________________________________________
> 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/20160711/0fb91b8c/attachment.html>


More information about the swift-evolution mailing list