<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><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 think it’d more readable to move type constraints to the where clause, but I don’t know if it needs to be a requirement.</div><div class=""><br class=""></div><div class="">I really like your implicit typealias idea…</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Foo&lt;Element: T,&nbsp;<span style="color: rgb(187, 44, 162);" class="">_</span>:&nbsp;U <span style="color: rgb(187, 44, 162);" class="">where</span> T: Comparable&gt; {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">&nbsp; &nbsp; //&nbsp;implicit typealias Element = T</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(187, 44, 162);" class="">typealias</span> </span><font face="Menlo" class=""><span style="font-size: 11px;" class="">Bar</span></font><font color="#008400" style="font-family: Menlo; font-size: 11px;" class=""> = </font><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">U&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// not&nbsp;</span><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">implicit because U didn</span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">’t have a label</span></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div class=""><br class=""></div>On Jan 23, 2016, at 19:18, Andrew Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">I like the idea.</div><div class=""><br class=""></div><div class="">I think I'd be using typealias a lot to make things more concise, but that's not necessarily a problem.&nbsp;</div><div class=""><br class=""></div><div class="">How would I name the following parameter?</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; struct OrderedCollection&lt;T: Comparable&gt; {</font></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; }</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="arial, helvetica, sans-serif" class="">As I understand it, would I do it as follows?</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; struct OrderedCollection&lt;Element: T: Comparable&gt; {</font></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; }</font></div></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="arial, helvetica, sans-serif" class="">Or would all type constraints now require `where`, like this:</font></div><div class=""><div class=""><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; struct OrderedCollection&lt;Element: T where T: Comparable&gt; {</font></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; }</font></div></div></div><div class=""><br class=""></div><div class="">Also, a typealias seems somewhat redundant when the parameter is labelled:</div><div class=""><br class=""></div><div class=""><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; struct OrderedCollection&lt;Element: T where T: Comparable&gt; {</font></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; &nbsp; &nbsp; typealias Element = T</font></div><div class=""><font face="monospace, monospace" class="">&nbsp; &nbsp; }</font></div></div><div class=""><br class=""></div><div class="">I wonder if the typealias could be implied.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jan 24, 2016 at 9:52 AM, Dave Abrahams 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"><span class=""><br class="">
on Sat Jan 23 2016, David Sweeris &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
<br class="">
&gt; The title seems fairly self-explanatory. Does anyone else think this could be useful?<br class="">
&gt; struct True : BooleanType {…} // Just part of the example… not in the proposal (although I do like it)<br class="">
&gt; struct False : BooleanType {…}&nbsp; // Same<br class="">
&gt; // This is where the actual idea starts<br class="">
&gt; struct BigInt &lt;BaseType: T = Int, CanEqualZero: U = Yes where T: IntegerArithmeticType, U: BooleanType&gt; {…}<br class="">
&gt;<br class="">
&gt; The first parameter label could be skipped (or not), depending on<br class="">
&gt; whatever the rules for functions parameter labels ends up being<br class="">
&gt; (either way, they should be the same IMHO). Then variables could be<br class="">
&gt; declared like this:<br class="">
&gt; let foo =&nbsp; &nbsp;BigInt()&nbsp; &nbsp; &nbsp; // BigInt&lt;Int, No&gt;()<br class="">
&gt; let bar =&nbsp; &nbsp;BigInt&lt;Int32&gt;() // For when your data will be processed on a 32-bit platform or something<br class="">
&gt; let divisor = BigInt&lt;CanEqualZero: False&gt;()<br class="">
&gt;<br class="">
&gt; (The obvious follow-up suggestion is to then allow a generic type’s<br class="">
&gt; definition to change based on the results of logical operations<br class="">
&gt; performed purely on the types that are passed in, but I think that’s<br class="">
&gt; getting into “macro system” territory, and should probably be its own<br class="">
&gt; thing.)<br class="">
&gt;<br class="">
&gt; Anyway, thoughts?<br class="">
&gt;<br class="">
<br class="">
</span>+1<br class="">
<span class="HOEnZb"><font color="#888888" class="">--<br class="">
-Dave<br class="">
<br 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/mailman/listinfo/swift-evolution</a><br class="">
</font></span></blockquote></div><br class=""></div>
</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></body></html>