<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks, and I totally agree that there are decent 3rd party libraries, such as Async that wraps GCD (<a href="https://github.com/duemunk/Async" class="">https://github.com/duemunk/Async</a>). I submitted this because I feel it should not be solely the responsibility of 3rd party libraries to facilitate conformance of Apple API. Also, it puts the onus on newcomers to Swift, iOS, et al, to go find those 3rd party libraries. :]</div><div class=""><br class=""></div><div class="">Scott</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 13, 2016, at 9:51 AM, Radosław Pietruszewski &lt;<a href="mailto:radexpl@gmail.com" class="">radexpl@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Certainly looks much nicer, but considering a major theme Swift 4 is likely to be concurrency, and in the meantime, this is easily solved with a 3rd party library — is it worth it?</div><div class=""><br class=""></div><div class="">SE-0006 admittedly changes Objective-C APIs *a lot*, but in a predictable way, without redesigning it from scratch. So, aside from minor enhancements to CGRect and the like, this would be a precedent AFAICT.</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 13 Feb 2016, at 16:48, Scott Gardner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello everyone!</div><div class=""><br class=""></div><div class="">I would like to submit the following rough sketch of a proposal to revise the GCD API syntax to adhere to the API Design Guidelines, in order to gauge interest and collect feedback and suggestions.</div><div class=""><br class=""></div><div class="">Here is a preliminary proposal outline:</div><div class=""><div class=""><br class=""></div><div class="">Author: Scott Gardner</div><div class=""><div class=""><br class=""></div><div class=""><b class="">Introduction</b></div><div class=""><br class=""></div><div class="">I propose that the Grand Central Dispatch (GCD) API be revised. GCD function signatures use snake-casing and are devoid of parameter names. This syntax does not conform to the Swift API Design Guidelines (“API guidelines”).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b class="">Motivation</b></div><div class=""><br class=""></div><div class="">The GCD API provides a rich set of capabilities for writing concurrent code. Yet GCD’s syntax can be a barrier to entry for developers, because it does not conform to the API guidelines.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b class="">Proposed solution</b></div><div class=""><br class=""></div><div class="">I propose revising the GCD API to follow the API guidelines. For example, instead of writing the following code to execute an operation asynchronously and then return to the main queue, such as to update the UI...</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="" class=""> concurrentQueue = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">dispatch_queue_create</span><span style="" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"com.scotteg.concurrent"</span><span style="" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">DISPATCH_QUEUE_CONCURRENT</span><span style="" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">dispatch_async</span><span style="" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">concurrentQueue</span><span style="" class="">) {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">dispatch_async</span><span style="" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">dispatch_get_main_queue</span><span style="" class="">()) {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">…this should be able to written in a more Swifty manner, e.g.,...</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> concurrentQueue = GCDQueue(.Concurrent, withIdentifier: </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"com.scotteg.concurrent"</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">GCD.enqueueOn(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">concurrentQueue</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; GCD.enqueueOn(.Main) {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// ...</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b class="">Detailed design</b></div><div class=""><br class=""></div><div class="">TBD</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b class="">Impact on existing code</b></div><div class=""><br class=""></div><div class="">This would be a wholesale replacement of syntax for the GCD API. A utility should also be created to convert pre-existing GCD code to the new syntax.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><b class="">Alternatives considered</b></div><div class=""><br class=""></div><div class="">TBD</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I would really appreciate your comments and suggestions, and I'd certainly be willing and committed to completing this proposal based on community feedback.</div><div class=""><br class=""></div><div class=""><div class="">Thanks!</div><div class=""><div class="">Scott</div><div class=""><br class=""></div><div class="">--</div><div class="">Scott Gardner</div><div class=""><a href="http://scotteg.com/" class="">http://scotteg.com</a></div></div></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>