[swift-evolution] Lambda function syntax

Thorsten Seitz tseitz42 at icloud.com
Mon Dec 28 00:08:38 CST 2015


Am 27.12.2015 um 23:24 schrieb Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>:

>> In this mail I’m answering several statements made in this thread by different people, not only Brent’s mail from which I just picked the following snippet:
>> 
>>> let names = people.map => person { person.name }
>> 
>> For me that is more difficult to read than
>> 
>>    let names = people.map { person in person.name }
>> 
>> Especially when chaining is used, i.e.
>> 
>>    let names = people.filter => person { person.isFriend }.map => person { person.name }
>> 
>> (or would I have to add parentheses somewhere with this proposed syntax?)
>> 
>> vs.
>> 
>>    let names = people.filter { person in person.isFriend }.map { person in person.name }
>> 
> 
> I said in the email that => is too visually heavy for this role.

Sorry, I overlooked that.

> Here's something lighter, although I'm still not satisfied with it, and not seriously suggesting it:
> 
>    let names = people.map ~ person { person.name }

Symbols have this problem in general because they stand out. But the real problem comes from moving the parameters out of the braces. The symbol only highlights it.

> Or even:
> 
>    let names = people.map \person { person.name }
> 
> However, I'm really struggling to find anything that I actually like here. This may be one of those cases where we dislike what's there and explore a bunch of options, only to find out that the current thing actually is the least bad alternative after all.

:-)

-Thorsten 


More information about the swift-evolution mailing list