[swift-evolution] Spread Operator as Shorthand for Map

Stephen Celis stephen.celis at gmail.com
Thu Dec 17 06:41:05 CST 2015

> On Dec 17, 2015, at 12:20 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> My general stance remains that, while an interesting idea, adding a second behavior around dot abbreviation causes more confusion than it's worth (especially given that the behavior is not well understood—this thread being an example), and that {$0.whatever} is not a big burden over (.whatever).
> Who says it’s a different behavior? If `var foo: Bar` implies `static func foo(self: Self) -> Bar`, then this falls out of that behavior.

Ah, maybe my brain was just wired to look at things differently :) Where the rule right now is:

    where (Self) is expected
        accept .foo where (Self).foo -> (Self)

The rule suggested here is:

    where (Self -> T) is expected
        accept .foo where (Self).foo -> (Self -> T)

Really close, but the method signature needs to unravel to resolve, since `.foo` isn't on type (Self -> T). Not to say that it shouldn't, just that it doesn't.

> As for conflicts, the same issue exists with the unbound methods declared on a type, and in practice it doesn’t cause any problems.

Yup, that's because those unbound methods take arguments. The upstream discussion around a `.foo#get` makes sense for disambiguation, and type resolution generally avoids ambiguity.

I'm interested in more complex examples than mapping to a property. This kind of function unraveling could have interesting applications.


More information about the swift-evolution mailing list