[swift-evolution] When to use argument labels, part DEUX (was: when to use argument labels (a new approach))

Charles Kissinger crk at akkyra.com
Sat Feb 6 17:15:36 CST 2016


> On Feb 5, 2016, at 11:16 PM, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Feb 5, 2016, at 1:32 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> 
>> Given all the awesome feedback I've gotten on this thread, I went back
>> to the drawing board and came up with something new; I think this one
>> works.  The previously-stated goals still apply:
> 
>> [snip goals]
> 
>> P.S. Doug is presently working on generating new importer results, based
>>     on these guidelines, for your perusal.  They should be ready soon.
> 
> 
> Here’s a link:
> 
> 	https://github.com/apple/swift-3-api-guidelines-review/pull/10/files <https://github.com/apple/swift-3-api-guidelines-review/pull/10/files>
Well, I might be the only one, but I don’t like these diffs. There are only a few cases where I don’t prefer the original function signature. Function names ending in prepositions with no objects look odd to me. It seems like a strange choice to make the split in the middle of the prepositional phrase.

If, as now proposed, the description of the main focus of the function call is going to be moved from the function name to a label for the first parameter, why not just drop the preposition entirely? As in:

func copy(zone zone: Zone = nil) -> AnyObject
func loadValuesAsynchronously(keys keys: [String], completionHandler handler: (() -> Void)? = nil)
func tracks(mediaType mediaType: String) -> [AVAssetTrack]

Or put it in the argument label, to keep the prepositional phrase intact:

func copy(withZone zone: Zone = nil) -> AnyObject
func loadValuesAsynchronously(forKeys keys: [String], completionHandler handler: (() -> Void)? = nil)
func tracks(withMediaType mediaType: String) -> [AVAssetTrack]

—CK

> Feedback welcome!
> 
> 	- Doug
> 
> _______________________________________________
> 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/20160206/89c5a535/attachment.html>


More information about the swift-evolution mailing list