[swift-evolution] When to use argument labels, part DEUX

Charles Kissinger crk at akkyra.com
Thu Feb 11 12:41:17 CST 2016

> On Feb 11, 2016, at 4:02 AM, Gwendal Roué via swift-evolution <swift-evolution at swift.org> wrote:
> If such convention were to be adopted, we could throw away our favorite grep tools.
> Functions with many parameters are often more legible when their invocation is split across several lines. And generally speaking, a developer can liberally call a function on a single line, or on several lines:
> 	attachmentFor(image: …, extraParam: …)
> 	attachmentFor(
> 	    image: …,
> 	    extraParam: …)
> OK so now if I want to look for all invocations of attachmentFor(image:extraParam:) in my code, I have to look for "attachmentFor", and get all the unrelated results attachmentFor(data:…), attachmentFor(fileURL:…), etc.

The “Find>References” function in Xcode will let you specifically find functions like these that differ only in their parameter labels. As I mentioned earlier in this thread, if you’re on Linux or just using different tools, you’re right: it does become a difficult problem to do it reliably.


> Whereas if the function were named attachmentForImage(_:extraParam:), I could look for "attachmentForImage", and get much more precise search results.
> So… I’m happy people discuss how nice `attachmentFor(image:)` looks, and my opinion on how nice or ugly it looks is not my point. My point is that I want my tools to help me doing my job.
> Gwendal
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list