[swift-evolution] [Pitch] Improving capturing semantics of local functions

Tino Heth 2th at gmx.de
Tue Nov 21 04:06:04 CST 2017

> 5. func fn<T>[foo, bar](param: T) throws -> T where T: Equatable captures [foo, bar] { … }

I guess it can be considered good practice to start a line with the most important information, and move the details to the far right, so that they don’t distract the hasty reader.
I’m not sure if the capture list an example for this, but for good or worse, it didn’t draw much attention in another position either (the first „[foo, bar]“ that slipped through).

That variant (func fn<T>[foo, bar](param: T)) is definitely my favorite, because it keeps a characteristic of closures (first the capture list, then the parameters), but doesn’t carry over the mingling of body and parameters that has to be done in closures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171121/90878f1b/attachment.html>

More information about the swift-evolution mailing list