[swift-evolution] Stdlib closure argument labels and parameter names

Dave Abrahams dabrahams at apple.com
Mon Jun 27 08:10:00 CDT 2016

on Sun Jun 26 2016, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:

> On Sun, Jun 26, 2016 at 2:18 PM, Erica Sadun via swift-evolution <
> swift-evolution at swift.org> wrote:
>> See below.  But in a nutshell, `do` gets the idea across. It's short.
>> It's pithy.  It uses a common, comfortable word. So yes, personal
>> taste. But it's personal taste backed up by some statistics.
> I've made this comment previously in another thread, but I'll chime in here
> because it seems pertinent. Just like the parentheses around function
> arguments can imply the word "with" or "using," and just as Swift 3 renamed
> `foo(atIndex: Int)` to `foo(at: Int)` because an argument of type Int
> implies an index, a closure to me implies the word "do," "invoke,"
> "perform" or even "soEach." After all, it's absurd that a closure would be
> supplied as an argument for any purpose other than being done or invoked or
> performed. 

Not at all.

    callbacks.append( { print("ring ring") } )

> That a label such as `do` or `body` or `soEach` could be applied so
> broadly seems to me a good sign that these labels might be extraneous.

I totally buy that argument when it comes to `do` or `body`.  That said,
as I have pointed out many times, “soEach” has very specific
communicative value that none of these others do.


More information about the swift-evolution mailing list