<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thank you Felix and Sean for the advice. I am happy to cautiously withdraw my suggestion, since this is a mostly acceptable workaround. The only hiccup appears to be with where inline documentation should be placed to have it appear in Xcode (in the extension, not the original protocol). I will think further and perhaps file a radar for Xcode later.<div class=""><br class=""></div><div class="">Incidentally, having explored the mailing lists further it seems that stuff like my original post should start in the swift-users list then works it's way over here. Would that be correct? I don't want to be extra noise in the wrong place.</div><div class=""><br class=""></div><div class="">- Ben<br class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 4 Dec 2015, at 16:37, Felix Gabel <<a href="mailto:felix.gabel@me.com" class="">felix.gabel@me.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">Default parameters are in my opinion an implementation detail and should be always handled by the conforming type. What can be done here is only declare the 4th method in the protocol and create a protocol extension with default forwarding.</div><div class=""><br class="">On 04 Dec 2015, at 17:31, Ben <<a href="mailto:ben_cocoa_dev_list@yahoo.co.uk" class="">ben_cocoa_dev_list@yahoo.co.uk</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class="">Hi list,<div class=""><br class=""></div><div class="">I propose that methods defined in protocols should accept default arguments. This could help remove the need for method families where only one parameter is essential, but others are often used.</div><div class=""><br class=""></div><div class="">For example:</div><div class=""><br class=""></div><div class="">protocol Datastore {</div><div class=""> func executeQuery(query: String)</div><div class=""> func executeQuery(query: String, usingParameters: [Any])</div><div class=""> func executeQuery(query: String, usingParameters: [Any], logType: LogType)</div><div class=""> func executeQuery(query: String, usingParameters: [Any], logType: LogType, completionHandler:ClosureOfSomeSort)</div><div class="">}</div><div class=""><br class=""></div><div class="">Where typically the implementing object funnels the first three methods through to the final, more verbose method.</div><div class=""><br class=""></div><div class="">This could be shortened to:</div><div class=""><br class=""></div><div class=""><div class="">protocol Database {</div><div class=""> func executeQuery(query: String, usingParameters: [Any] = [], logType: LogType = .NotLogged completionHandler:ClosureOfSomeSort? = nil)</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Advantages:</div><div class="">- Only one method to implement</div><div class="">- Less to document, less cluttered interface</div><div class="">- Prevent objects adopting the protocol from using different default values</div><div class="">- Prevent objects from implementing similar methods in the family differently - fewer code paths to inspect, less confusion over behaviour since no argument values are hidden</div><div class=""><br class=""></div><div class="">This fits in well with the parameters section of the Swift API design page: <a href="https://swift.org/documentation/api-design-guidelines.html#parameters" class="">https://swift.org/documentation/api-design-guidelines.html#parameters</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">What do you think?</div><div class=""><br class=""></div><div class="">Regards,</div><div class=""><br class=""></div><div class="">Ben Barnett</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=T04LrBojaExXAX0mv-2F2MMtIB9rMFpWjvqf12Pj37IVJ-2FsU837QZ6P4QGPieGfVoMxOwRl-2B-2Bg9Es-2BxNNVtZeXHOqZuQJ-2Bv0B7ohE-2FvLSOGiB9CrlDNyobNQ8p1B7-2F-2BylOSvyuZe7fdyIba7BssFiAr69MFcNiIxKtbG4fulekDUfR5JBCiEkE8CFduV8B9LbQQV8BOSJU2HaGi28344V4F6tyHkRRni1gsgHuVI30iis-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></div></body></html>