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

James Froggatt james.froggatt at me.com
Thu Jul 21 04:11:49 CDT 2016


Marking the return value is certainly a direction we could go, but my reasoning in this proposal was that ‘-> inout’ is semantically equivalent to the colon, as it exists today for computed properties.
I think this the result of this proposal will set the precedent for if/when we do add this feature, and personally I'd prefer the cleaner syntax of the colon.

------------ Begin Message ------------ 
Group: gmane.comp.lang.swift.evolution 
MsgID: <E901B7CF-2640-4C6F-BC5B-0483D45D2AE2 at architechies.com> 

>On Jul 20, 2016, at 12:58 PM, Garth Snyder via swift-evolution <swift-evolution at swift.org> wrote:
> 
> However, the current notation of -> Type being used to declare an input parameter to set {} just strikes me as weird and wrong. The symbol -> means “returns a” or “yields”. Since we’re declaring a type that might be either inbound or outbound, the neutral : is more appropriate.

If, as seems likely for lens support, we eventually supported inout functions:

func foo(x: Int) -> inout String {
get { return myStr }
set { myStr = newValue }
}

Would you feel differently about having `:` on subscript returns? Or would you want to use `:` on inout functions, too?

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
swift-evolution at swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
:

------------- End Message ------------- 



From James F


More information about the swift-evolution mailing list