<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 26, 2016, at 3:40 AM, 张国晔 via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Functions in Swift can have default parameters or discardable result, but without inlining, calling them could be suboptimal in performance.<br class=""><br class="">I propose a solution which compiler generates specializations of those functions, hence more optimization can be performed for specific usage.<br class=""><br class="">This can also be used to solve binary compatibility when new parameters are added to a function.<br class=""><br class=""><br class="">Draft:<br class=""><a href="https://github.com/cc941201/swift-evolution/blob/master/proposals/NNNN-function-specialization.md" class="">https://github.com/cc941201/swift-evolution/blob/master/proposals/NNNN-function-specialization.md</a><br class=""></div></div></blockquote><br class=""></div><div><div>Thanks for the proposal. In the long run, we will probably have</div><div>API-level annotation for explicit specialization, as you are</div><div>proposing. But it's best to first experiment with different forms of</div><div>specialization, both automatic and annotation driven, internally</div><div>before proposing the language feature. Currently, the optimizer</div><div>performs a variety of automatic function specialization within a</div><div>module (with -whole-module-optimization). We also have an explicit</div><div>form of generic specialization (using @_specialize), which is hidden</div><div>from the Module's API. We don't yet have an explicit annotation that</div><div>allows specializing for argument values and for dead arguments and return</div><div>values since we haven't seen a compelling performance need to do that</div><div>across Module boundaries.</div><div><br class=""></div><div>Exposing explicit function specialization as an API feature will</div><div>require specifying the affect on library evolution. We're deferring that</div><div>issue until other aspects of library evolution are sorted out:</div><div><a href="https://github.com/apple/swift/blob/master/docs/LibraryEvolution.rst" class="">https://github.com/apple/swift/blob/master/docs/LibraryEvolution.rst</a></div><div class=""><br class=""></div><div class="">-Andy</div></div><br class=""></body></html>