<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<Element: T, <span style="color: rgb(187, 44, 162);" class="">_</span>: U <span style="color: rgb(187, 44, 162);" class="">where</span> T: Comparable> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""> // 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=""> <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 </span><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// not </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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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. </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=""> struct OrderedCollection<T: Comparable> {</font></div><div class=""><font face="monospace, monospace" class=""> }</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=""> struct OrderedCollection<Element: T: Comparable> {</font></div><div class=""><font face="monospace, monospace" class=""> }</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=""> struct OrderedCollection<Element: T where T: Comparable> {</font></div><div class=""><font face="monospace, monospace" class=""> }</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=""> struct OrderedCollection<Element: T where T: Comparable> {</font></div><div class=""><font face="monospace, monospace" class=""> typealias Element = T</font></div><div class=""><font face="monospace, monospace" class=""> }</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=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
<br class="">
> The title seems fairly self-explanatory. Does anyone else think this could be useful?<br class="">
> struct True : BooleanType {…} // Just part of the example… not in the proposal (although I do like it)<br class="">
> struct False : BooleanType {…} // Same<br class="">
> // This is where the actual idea starts<br class="">
> struct BigInt <BaseType: T = Int, CanEqualZero: U = Yes where T: IntegerArithmeticType, U: BooleanType> {…}<br class="">
><br class="">
> The first parameter label could be skipped (or not), depending on<br class="">
> whatever the rules for functions parameter labels ends up being<br class="">
> (either way, they should be the same IMHO). Then variables could be<br class="">
> declared like this:<br class="">
> let foo = BigInt() // BigInt<Int, No>()<br class="">
> let bar = BigInt<Int32>() // For when your data will be processed on a 32-bit platform or something<br class="">
> let divisor = BigInt<CanEqualZero: False>()<br class="">
><br class="">
> (The obvious follow-up suggestion is to then allow a generic type’s<br class="">
> definition to change based on the results of logical operations<br class="">
> performed purely on the types that are passed in, but I think that’s<br class="">
> getting into “macro system” territory, and should probably be its own<br class="">
> thing.)<br class="">
><br class="">
> Anyway, thoughts?<br class="">
><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>