[swift-evolution] Brainstorming: Optional sugar inferred map

Joe Groff jgroff at apple.com
Sat Jan 30 12:28:07 CST 2016


> On Jan 27, 2016, at 11:34 PM, Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I've wanted this sort of thing a lot. It would also work for other functions, such as
> 
>     manager.doSomething(data: data, count: n?)
> 
> which is equivalent to
> 
>     n.map { manager.doSomething(data: data, count: $0) }
> 
> It might be hard to see exactly which operator/function applications such a thing applies to, if used in the context of a complex expression.

Yes, this would be a major problem with this sort of feature. Without some explicit delimiter for the bounds of the map operation, you have either extremely subtle rules for defining the implicit bounds, or an exponential type-checking problem figuring it out from context. 

-Joe


More information about the swift-evolution mailing list