[swift-evolution] Lambda function syntax

Alexander Regueiro alexreg at gmail.com
Wed Dec 23 15:48:05 CST 2015


Marking the *start* of a closure is more difficult than marking the end of the parameter the list. The end of the parameter list and start of the body of a closure (lambda expression) can be easily delineated by `{` in my scheme.

> On 23 Dec 2015, at 21:15, Brent Royal-Gordon <brent at architechies.com> wrote:
> 
>> This is very similar to my proposal. We were later suggesting the use of `=>` in place of `in`, but formerly I suggested essentially what you did here, but with `func` or `\` in place of `>=` to signify the start of a closure expression.
> 
> It seems, though, that you thought *all* closures should be marked with this character, even parameterless ones. Whereas I propose that:
> 
>>> A no-parameters closure would not require a `=>`; a bare block would still do there.
> 
> Perhaps it's a difference in perspective—I've spent nearly my entire career using languages where closures were common—but I really don't think closures need a big, obvious syntactic marker. All we need is a good way to mark the ambiguous end of the parameter list (the front end if it's outside the closure, the back end if it's inside).
> 
> Closures are not conceptually a terribly difficult feature—they're just omitted from many languages because they're difficult to *implement*. We have to be careful not to make their syntax heavier than it needs to be.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 



More information about the swift-evolution mailing list