<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=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 24 Jan 2017, at 05:10, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">While it looks nicer without the angle brackets, that suggestion is unresponsive to David's point that we need some way to distinguish defaulted generic arguments from inferred generic arguments.<div class=""><br class=""></div><div class="">Consider:</div><div class="">```</div><div class="">let a: Optional = 1 // Optional&lt;Int&gt;</div><div class=""><br class=""></div><div class="">enum FloatPreferringOptional&lt;T = Float&gt; {</div><div class="">&nbsp; case some(T)</div><div class="">&nbsp; case none</div><div class="">}</div><div class=""><br class=""></div><div class="">let b: FloatPreferringOptional = 1</div><div class="">// Does this give you an FloatPreferringOptional&lt;Int&gt;?</div><div class="">```</div><div class=""><br class=""></div><div class="">If the answer to the above question is "yes, T is inferred as Int" then we need some way to express "give me the default for T, which is Float." If the answer to the above question is "no" then we need some way to express "don't give me the default; rather, infer type T from the right hand side."</div><div class=""><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jan 23, 2017 at 6:30 PM, Matthew Johnson via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><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="">This proposal looks good to me.&nbsp; I have been looking forward to more flexible generic arguments for a while.<div class=""><br class=""></div><div class="">I agree with previous commenters who prefer the option to leave off the angle brackets when all parameters have defaults.</div><div class=""><br class=""></div><div class="">The proposal specifically mentions that the syntax is inspired by that of function arguments.&nbsp; This is good, but I wonder if maybe we should draw further inspiration from function arguments and also add parameter labels for generic arguments.&nbsp; Both feel like low hanging fruit in the generics area (correct me if I’m wrong about that) and it would be great to see both enhancements make it into Swift 4.</div><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Jan 23, 2017, at 9:55 AM, Srđan Rašić via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-2275226256302434135Apple-interchange-newline"></div></div><div class=""><div class=""><div class="h5"><div dir="ltr" class="">Hi Everyone,<div class=""><br class=""></div><div class="">I've opened a PR (<a href="https://github.com/apple/swift-evolution/pull/591" target="_blank" class="">https://github.com/apple/<wbr class="">swift-evolution/pull/591</a>)&nbsp;<wbr class="">proposing default generic arguments which I think would be nice addition to the language. They are also mentioned in "Generic manifesto".&nbsp;</div><div class=""><br class=""></div><div class="">The proposal is focusing around generic types. Generic functions are not coved by the proposal and I don't think that we need default generic arguments in generic functions as all the types are always part of the function signature so the compiler can always infer them. One corner case might be if using default argument values in which case support for default generic arguments in functions might be useful.</div><div class=""><br class=""></div><div class="">It would be great to hear your opinions and suggestions so I can refine the proposal.<br class=""></div></div></div></div><span class="">
______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class=""></span></div></blockquote></div><br class=""></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">I was watching this talk recently by Bjarne Stroustrup (<a href="https://youtu.be/2egL4y_VpYg?t=26m34s" class="">https://youtu.be/2egL4y_VpYg?t=26m34s</a>), he was saying that when new things are added to a language, people tend to want very loud syntax just because it’s new and people want it to be obvious and fool-proof. That’s why C++ syntax is such a mess.</div></div><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">Personally, I’m fine leaving the angle brackets away if there is a default value. If the expected type is not the one inferred by the initialiser, you will hit compiler errors and be able to explicitly say which value the parameter should have. It’s not an unreasonable cognitive load.</div><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">- Karl</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>