[swift-evolution] [Pitch] Align label behavior for subscripts

Adrian Zubarev adrian.zubarev at devandartist.com
Tue Sep 20 05:36:51 CDT 2016


This is probably something additional and it might already have been discussed here somewhere, I apologize if I missed that talk.

The rule for parameter labels on functions was fixed in Swift, but now it kinda feels odd to have a different pair of rules for subscripts (at least it does feel odd to me).

// Is fine when the names are different
subscript(externalName internalName: ParamType) -> ElementType {
    get { … }
    set { … }
}

something[externalName: …]

// We had this with functions already, remeber?
subscript(sameName sameName: ParamType) -> ElementType {
    get { … }
    set { … }
}
Aligning this wouldn’t break anything. I believe this can be migrated easily.

// No label!
subscript(_ internalName: ParamType) -> ElementType {
    get { … }
    set { … }
}

something[externalName: …]

// Label name is the same as the parameter name
subscript(sameName: ParamType) -> ElementType {
    get { … }
    set { … }
}

// Different names
subscript(externalName internalName: ParamType) -> ElementType {
    get { … }
    set { … }
}
I know this might be something for stage 2, and I apologize again for posting this early, but we need a better way to keep ideas alive and not forget them after a half of a year. ;) (Forum?)



-- 
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160920/72bcc942/attachment.html>


More information about the swift-evolution mailing list