[swift-evolution] Spread Operator as Shorthand for Map

Dennis Lysenko dennis.s.lysenko at gmail.com
Wed Dec 16 10:52:35 CST 2015


Ignore the above. Thought make was a method for some reason. Still, it
would be possible if the parallel proposal for adding method references for
getters were approved.

On Wed, Dec 16, 2015, 11:51 AM Dennis Lysenko <dennis.s.lysenko at gmail.com>
wrote:

> Perhaps cars.map(Car.make)? We already have method references, why define
> a new syntax?
>
> On Wed, Dec 16, 2015, 11:18 AM Stephen Celis via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> On Wed, Dec 16, 2015 at 10:50 AM, Matthew Johnson via swift-evolution <
>> swift-evolution at swift.org> wrote:
>>
>> If we peel off just the contextual shorthand aspect of this proposal you
>>> could write:
>>>
>>> cars.map(.make)
>>>
>>> That does seem like a big win if it is feasible (doesn’t introduce
>>> ambiguity or cause other significant challenges in implementation).
>>>
>>
>> The above creates ambiguity if there were a `map` function that takes a
>> type with a static member `make`.
>>
>> Alternatively:
>>
>>     cars.map{.make}
>>
>> Both create an additional meaning for dot abbreviation, though, which is
>> confusing. I think I'm "-1" on this proposal as is. The existing form is
>> clearer and relatively short as is.
>>
>> Stephen
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/b078b51e/attachment.html>


More information about the swift-evolution mailing list