I would like to see some kind of feature like this. In my own codebase, I have wanted protocol metatype properties with less complex cases, in the following approximate pattern:
protocol CustomDelegate {
func complexRequirementsHere()
}
class DefaultCustomDelegate : CustomDelegate {
}
func performAction(withDelegate delegate: CustomDelegate) {
....
}
performAction(withDelegate: .default) // versus currently performAction(withDelegate: DefaultCustomDelegate())
The way I imagined this feature being expressed is something like
extension CustomDelegate.Type {
var `default`: DefaultCustomDelegate { return DefaultCustomDelegate() }
}
It feels like it falls out quite naturally, with the goal of better call-site readability. Admittedly, I haven't thought of all the possible applications of this, like more complex generic expressions, but I thought I'd contribute another motivating use case (and syntax suggestion) to the thread.
Last year, I identified where this could potentially be used to improve the RandomNumberGenerator API.