<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="">As mentioned in my prior message, I currently have a PR open to update the generics manifesto (<a href="https://github.com/apple/swift/pull/13012" class="">https://github.com/apple/swift/pull/13012</a>). I removed one topic from that update at Doug Gregor’s request that it be discussed on the list first. </div><div class=""><br class=""></div><div class="">The idea is to add the ability to make default arguments conditional (i.e. depend on generic constraints). It is currently possible to emulate conditional default arguments using an overload set. This is verbose, especially when several arguments are involved. Here is an example use case using the overload method to emulate this feature:</div><div class=""><br class=""></div><div class="">```swift</div><div class="">protocol Resource {</div><div class=""> associatedtype Configuration</div><div class=""> associatedtype Action</div><div class="">}</div><div class="">struct ResourceDescription<R: Resource> {</div><div class=""> func makeResource(with configuration: R.Configuration, actionHandler: @escaping (R.Action) -> Void) -> R {</div><div class=""> // create a resource using the provided configuration</div><div class=""> // connect the action handler</div><div class=""> // return the resource</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class="">extension ResourceDescription where R.Configuration == Void {</div><div class=""> func makeResource(actionHandler: @escaping (R.Action) -> Void) -> R {</div><div class=""> return makeResource(with: (), actionHandler: actionHandler)</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class="">extension ResourceDescription where R.Action == Never {</div><div class=""> func makeResource(with configuration: R.Configuration) -> R {</div><div class=""> return makeResource(with: configuration, actionHandler: { _ in })</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class="">extension ResourceDescription where R.Configuration == Void, R.Action == Never {</div><div class=""> func makeResource() -> R {</div><div class=""> return makeResource(with: (), actionHandler: { _ in })</div><div class=""> }</div><div class="">}</div><div class=""><br class=""></div><div class="">```</div><div class=""><br class=""></div><div class="">Adding language support for defining these more directly would eliminate a lot of boilerplate and reduce the need for overloads. Doug mentioned that it may also help simplify associated type inference (<a href="https://github.com/apple/swift/pull/13012#discussion_r152124535" class="">https://github.com/apple/swift/pull/13012#discussion_r152124535</a>).</div><div class=""><br class=""></div><div class="">The reason that I call this a pre-pitch and one reason Doug requested it be discussed on list is that I haven’t thought of a good way to express this syntactically. I am interested in hearing general feedback on the idea. I am also looking for syntax suggestions.</div><div class=""><br class=""></div><div class="">Matthew</div></body></html>