<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 24, 2017, at 5:52 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On Wed, May 24, 2017 at 7:21 PM, David Sweeris<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:davesweeris@mac.com" target="_blank" class="">davesweeris@mac.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 24, 2017, at 5:11 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-5784497114239993718m_-8141685891239421842Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Wed, May 24, 2017 at 3:32 PM, David Sweeris via swift-evolution<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class="">So, I’m working on a type, and would like to make it conform to `ExpressibleByArrayLiteral`. The thing is, I don’t actually care what type `Element` is as long as it conforms to `FixedWidthInteger` and `UnsignedInteger`. I tried writing this:<div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">init</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span>&lt;U:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">FixedWidthInteger</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span>&amp;<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">UnsignedInteger</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt; (arrayLiteral elements:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">U</span><span style="font-variant-ligatures: no-common-ligatures;" class="">...) {&nbsp;</span>… }</div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">But Xcode says my type doesn’t conform to `ExpressibleByArrayLiteral` unless I add an init that takes a concrete type:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">init</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(arrayLiteral elements:<span class="Apple-converted-space">&nbsp;</span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">UInt</span><span style="font-variant-ligatures: no-common-ligatures;" class="">...) {</span><font face="Menlo" class="">&nbsp;</font><font face="Menlo" class="">…</font>&nbsp;}</div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">Does anyone else think the generic init should to be able to satisfy `ExpressibleByArrayLiteral` (especially since `UInt` meets the conformance requirements)?</span></div></span></div></div></blockquote><div class=""><br class=""></div><div class="">Your type needs to be generic.</div></div></div></div></div></blockquote><br class=""></div></span><div class="">It already is… I just don’t want to restrict it to being initialized from array literals containing that same generic type.</div></div></blockquote><div class=""><br class=""></div><div class="">Not sure of your particular use case, but it sounds like you'd want to write a type-erased AnyFixedWidthUnsignedInteger wrapper.</div></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">It’s just a arbitrary-width integer type. It's generic over a “chunk” type: UIntArb&lt;UInt8&gt;, UIntArb&lt;UInt32&gt;, etc. I was just wanting to be able initialize the chunk array using an array literal containing any FixedWidthInteger &amp; UnsignedInteger type is all. I’ll look into the type-erased wrapper thing, but I doubt it’ll be worth the effort since it was just a minor convenience issue for me in the first place.</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div></body></html>