You could use dispatch(), and name the synchronous method something else? 
synchronize() or its shortened form sync(), which is a real word, or maybe 
wait(). (However, there was a beauty in the yin-yang of async/sync in the 
original API. I would call them terms of art, like map, filter, reduce, etc)


class DispatchQueue : DispatchObject {
    func synchronize(work: @convention(block) () -> Void)

    func dispatch(
        group: DispatchGroup? = nil, 
        qos: DispatchQoS = .unspecified, 
        flags: DispatchWorkItemFlags = [], 
        work: @convention(block) () -> Void)
}

queue.dispatch(group: group) {
    print("Hello World")
}

queue.synchronize {
    print("Hello World")
}


> On 12 May 2016, at 12:50 AM, James Dempsey via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
>> So maybe that will conform to the API naming guideline?  Or would the verb 
>> have to be in the base name of the func?
> 
> 
> It seems from the guidelines that the intent is for the verb to be in the 
> base name of the func, especially since there is another set of guidelines 
> for naming function parameters.
> 
> In general the other methods in the proposal are verbs (perform(), notify(), 
> wait(), cancel(), etc.)
> 
> At least for me, not including a verb makes the API read like the sentence 
> “The dog quickly”.  This wasn’t so bad in the C API, because you could read 
> the word ‘dispatch’ as the verb.
> 
> 
> Looking at the current GDC API, it does seem like dispatching synchronously 
> is the rare and special case.
> 
> Could there be just a single dispatch() method, with async as a flag with a 
> default value of true?
> 
> It might be a little ugly because most of the other parameters of the 
> proposed asynchronously() method would not apply in the sync case.
> 
> James
> 
> 
> 
>> On May 11, 2016, at 7:14 AM, Ricardo Parada <rpar...@mac.com 
>> <mailto:rpar...@mac.com>> wrote:
>> 
>> Jacob Bandes-Storch suggested:
>> 
>> synchronously(execute work: …)
>> 
>> So maybe that will conform to the API naming guideline?  Or would the verb 
>> have to be in the base name of the func?
>> 
>> Or perhaps:
>> 
>> synchronously(dispatch work: …)
>> asynchronously(dispatch work: …)
>> 
>> 
>> 
>>> On May 11, 2016, at 9:32 AM, James Dempsey via swift-evolution 
>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>> 
>>> The method names
>>> 
>>>     synchronously()
>>>     asynchronously() 
>>> 
>>> are both adverbs, not noun phrases or verb phrases.
>>> These methods have side effects, so each name should have a verb in it to 
>>> make it a verb phrase.
>>> 
>>> 
>>> Since these are the methods where you actually dispatch a block into a queue
>>> 
>>> dispatchSynchronously()
>>> dispatchAsynchronously()
>>> 
>>> would include the verb in the name of the methods.
>>> 
>> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to