<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="">The title seems fairly self-explanatory. Does anyone else think this could be useful?<div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">struct</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class=""> True : </span><font color="#703daa" face="Menlo" class=""><span style="font-size: 11px;" class="">BooleanType</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> {…} </span></font><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">// Just part of the example… n</span></font><span style="font-size: 11px; color: rgb(0, 132, 0); font-family: Menlo;" class="">ot in the proposal (although I do like it)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">struct</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class=""> False : </span><font color="#703daa" face="Menlo" class=""><span style="font-size: 11px;" class="">BooleanType</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> {…} </span></font><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">// Same</span></font></div></div><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class="">// This is where the actual idea starts</span></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-size: 11px; font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> BigInt <BaseType: T = <span style="color: rgb(112, 61, 170);" class="">Int</span>, CanEqualZero: U = <span style="color: rgb(79, 129, 135);" class="">Yes </span><span style="color: rgb(187, 44, 162);" class="">where</span> T: IntegerArithmeticType, U: BooleanType> {…}</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">The first parameter label could be skipped (or not), depending on whatever the rules for functions parameter labels ends up being (either way, they should be the same IMHO). Then variables could be declared like this:</div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> foo = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">BigInt</span>()<span class="Apple-tab-span" style="white-space:pre">        </span> <span style="color: rgb(0, 132, 0);" class="">// BigInt<Int, No>()</span></div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" style="font-size: 11px;" class=""><span style="color: rgb(187, 44, 162);" class="">let</span><font class=""> bar = </font><span style="color: rgb(79, 129, 135);" class="">BigInt</span><font class=""><Int32>() </font><span style="color: rgb(0, 132, 0);" class="">// For when your data will be processed on a 32-bit platform or something</span></font></div></div></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">let</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> divisor = </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">BigInt</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""><CanEqualZero: </span></font><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">False</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">>()</span></font></div><div style="font-family: Menlo; font-size: 11px;" class=""><br class=""></div></div></div><div class="">(The obvious follow-up suggestion is to then allow a generic type’s definition to change based on the results of logical operations performed purely on the types that are passed in, but I think that’s getting into “macro system” territory, and should probably be its own thing.)</div><div class=""><br class=""></div><div class="">Anyway, thoughts?</div></div></div><br class=""><div class="">
- Dave Sweeris
</div>
<br class=""></body></html>