[swift-evolution] [Proposal draft] Generalized Naming for Any Function

Joe Groff jgroff at apple.com
Mon Dec 28 15:14:18 CST 2015


> On Dec 28, 2015, at 1:09 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
> 
>> and you could access the unapplied lens for an instance property using `Type.property` syntax, analogous to how `Type.method` works. I feel like if we did that, then it would obviate the need for explicit `property.get` or `property.set` for most native Swift uses, though maybe not ObjC interop uses.
> 
> I feel like if you don't have a way to fetch an unbound getter, you're missing the 90% case, which is constructs like:
> 
> 	let textValues = textViews.map(.#text.get)

Agreed. I think there are a couple ways to approach that. We could resolve unbound property references contextually, so that Type.property gives you the getter in normal function context, or the lens in inout function context, and/or either allow implicit upconversion from lens to getter function or provide an explicit getter((inout T) -> inout U) -> T -> U adapter function.

-Joe


More information about the swift-evolution mailing list