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