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

Mila Schultz mila.schultz at gmail.com
Mon Feb 8 13:49:07 CST 2016


The current set of rules are causing methods with completion handlers to be imported inconsistently. Sometimes the method name includes With, but sometimes it does not. 

For example,

// no With
 -  func exportAsynchronouslyWithCompletionHandler(handler: () -> Void)
 +  func exportAsynchronously(completionHandler handler: () -> Void) 

// yes With
 -  func determineCompatibleFileTypesWithCompletionHandler(handler: ([String]) -> Void)
 +  func determineCompatibleFileTypesWith(completionHandler handler: ([String]) -> Void)

// no With
 -  func finishWritingWithCompletionHandler(handler: () -> Void)
 +  func finishWriting(completionHandler handler: () -> Void)

// no and yes With
 -  func savePresentedItemChangesWithCompletionHandler(completionHandler: (Error?) -> Void)
 -  func accommodatePresentedItemDeletionWithCompletionHandler(completionHandler: (Error?) -> Void)
 +  func savePresentedItemChanges(completionHandler completionHandler: (Error?) -> Void)
 +  func accommodatePresentedItemDeletionWith(completionHandler completionHandler: (Error?) -> Void)

Perhaps eliminating “with” before parentheses in these cases is the way to go, especially since many completion handlers are good candidates to have default values, as suggested by the Guidelines:

extension Document {
  func close(completionHandler completion: ((Bool) -> Void)? = nil)
}

My apologies if this is irrelevant or has already been discussed!

Mila

> On Feb 8, 2016, at 10:31 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> on Mon Feb 08 2016, Jonathan Tang <jonathan.d.tang-AT-gmail.com> wrote:
> 
>> None of this is what I'd consider a deal-breaker, and I know the review
>> period has ended, but if a decision hasn't been made yet and you're on the
>> fence, please consider. :-)
> 
> Thanks for your insight, Jonathan.  Yes, the review period is formally
> over but we've now entered the “what, exactly, do we do with the results
> of this discussion?” phase.  More discussion is certainly welcome at any
> time.
> 
> -- 
> -Dave
> _______________________________________________
> 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