<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 Nov 28, 2017, at 3:18 PM, Slava Pestov &lt;<a href="mailto:spestov@apple.com" class="">spestov@apple.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; line-break: after-white-space;" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 28, 2017, at 8:44 AM, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">func makeResource(</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">&nbsp; &nbsp; with configuration: Configuration = () where Configuration == Void,&nbsp;</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">&nbsp; &nbsp; actionHandler: @escaping (Action) -&gt; Void = { _ in } where Action == Never</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">)</div></div></blockquote></div><br class=""><div class="">Similar question to the one I posed earlier — what happens if I’m using makeResource() from a generic context? Is the conditional default argument simply not available?</div></div></div></blockquote><div><br class=""></div><div>Right. &nbsp;If the constraints are not met at the call site the default is not available. &nbsp;I think you understood, but looking at the example above I omitted the resource type parameter. &nbsp;It should read:</div><div><br class=""></div><div>func makeResource&lt;R: Resource&gt;(<br class="">&nbsp; &nbsp; with configuration: R.Configuration = () where R.Configuration == Void,&nbsp;<br class="">&nbsp; &nbsp; actionHandler: @escaping (R.Action) -&gt; Void = { _ in } where R.Action == Never<br class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><div class=""><div class="">)</div></div></div></div></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">In this case, how is it different from defining some static overloads of makeResource(), some of which have default arguments and some of which are generic?</div></div></div></blockquote><div><br class=""></div><div>From the point of view of the call site it is not different. &nbsp;The differences are that:</div><div><br class=""></div><div>* the user is presented with a single API rather than several overloads</div><div>* the library author isn’t required to maintain an overload set</div><div>* the compiler doesn’t have to reason about an overload set which might improve build times, etc</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Slava</div></div></div></blockquote></div><br class=""></body></html>