[swift-evolution] Revisiting SE-0110

Chris Lattner clattner at nondot.org
Thu May 25 01:08:41 CDT 2017


> On May 24, 2017, at 12:12 PM, Tony Parker via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hi everyone,
> 
> We received a pull request in swift-corelibs-foundation which is apparently in response to a language change for SE-0110.
> 
> It turns this perfectly reasonable code:
> 
> -        self.forEach { (keyItem, valueItem) in
> 
> into this:
> 
> 
> +        self.forEach { (arg) in
> +            let (keyItem, valueItem) = arg
> 
> Is that really the design pattern we want to encourage? What was wrong with the previous code?

For consistency, the decision was to make closure parameter lists work the same way as function parameters.  Function parameters do not allow destructuring of arguments in their declaration, so it seemed weird to let closures do that.

Similarly, this doesn’t compile either:

	self.ForEach(functionTakingTwoParameters)

even if the two parameters are equivalent to the element type of the self Sequence

-Chris


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170524/f3915099/attachment.html>


More information about the swift-evolution mailing list