<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="">I forgot to reply to the email list here.</div><div class=""><br class=""></div><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 26, 2016, at 10:03 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Did you mean to reply offlist?<br class=""><br class="">Basically, a factory would be:<br class=""><br class="">func make<T>(_: T.Type) -> T { return T() }<br class=""><br class="">but you need T to conform to a protocol that guarantees T.init(). You use it like:<br class=""><br class="">make(Foo.self)<br class=""><br class="">But one can write:<br class=""><br class="">func make<T>(_ f: @autoclosure () -> T) -> T { return f() }<br class=""><br class="">and use this like:<br class=""><br class="">make(Foo())<br class=""><br class="">(pardon typos; freehanding on iPad)<br class=""><br class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 26, 2016 at 23:58 Braeden Profile <<a href="mailto:jhaezhyr12@gmail.com" class="">jhaezhyr12@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Actually, I’m a little lost at this point of exactly how you could build a function with this pattern. Code, anyone?</div></div><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 26, 2016, at 9:57 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>> wrote:</div><br class="m_2382602459962088654Apple-interchange-newline gmail_msg"><div class="gmail_msg">With @autoclosure your user can simply write T() as an argument. It is very elegant and not complicated at all.<br class="gmail_msg"></div></blockquote></div></div></blockquote></div></div></blockquote></div><br class=""></div></div></div><br class=""></body></html>