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

Garth Snyder garth at garthsnyder.com
Thu Jul 21 01:20:28 CDT 2016

> Brent Royal-Gordon: 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?

Since I haven’t used lenses <https://en.wikipedia.org/wiki/Bidirectional_transformation> and had to look them up, I’m really not entitled to an opinion on this. But it’s an interesting question.

To the extent that one conceptualizes lenses as having a “natural" inherent directionality, it seems desirable for the declaration to express that. So at first glance, -> doesn’t seem out of place here.


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

More information about the swift-evolution mailing list