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

Brent Royal-Gordon brent at architechies.com
Mon Jun 27 21:06:23 CDT 2016


> 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.

In the calls at hand, like `withUnsafeMutablePointer`, "do" is the verb of the call. That is not true of many—perhaps most—closures. For instance, the verb of `map(_:)` is "map". The verb of `save(to:for:completionHandler:)` is "save".

On the other hand, in `withUnsafeMutablePointer(_:do:)`, the verb of the call really *is* "do". Doing the closure and causing its side effects to occur or its return value to be calculated is the entire purpose of that call. In a sense, the call is sort of backwards; if it weren't for the fact that closures are very long, it might be better written as `do(_:withUnsafeMutablePointer:)`.

(Hmm. *Technically* I suppose that call *ought* to be `withUnsafeMutablePointer(to:do:)`...)

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list