[swift-evolution] Revisiting SE-0110

Ben Cohen ben_cohen at apple.com
Wed May 24 20:18:03 CDT 2017

I very much agree with your concerns about this change in general.

On this specific example, though, I just wanted to point out that there doesn’t seem to be a good reason to use .forEach here.

for (key, value) in self {
  // etc

Would work perfectly well and is clearer IMO, still works with destructing, doesn’t have gotcha problems related to continue/break not doing what you might expect, etc. 

forEach is only really a win when used on the end of a chain of map/filter-like operations, where for…in would involve bouncing back from right to left.

> 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?
> (https://github.com/apple/swift-corelibs-foundation/pull/995/files <https://github.com/apple/swift-corelibs-foundation/pull/995/files>)
> - Tony
> _______________________________________________
> 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/20170524/e9c76b1f/attachment.html>

More information about the swift-evolution mailing list