[swift-evolution] Spread Operator as Shorthand for Map

Sean Heber sean at fifthace.com
Wed Dec 16 10:19:40 CST 2015


I’m not a macro expert, but I suspect that once there’s a macro system this sort of thing would be pretty easy to construct - possibly with something like:

macro using(x) { $0.x }
cars.map using(make)

I’d like this sort of thing to be possible, too, but I’m not sure it needs to be explicitly added to the language if a macro system is (eventually) coming.

l8r
Sean


> On Dec 16, 2015, at 9:50 AM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 
>> I’d like to write the following, but ‘make’ is a member, not a free function:
>> cars.map(make)
> 
> 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).  
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list