<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><div></div><div>I agree that Swift absolutely needs a static array type.</div><div><br></div><div>However, until then, here's a gist to generate the code for a static array struct:&nbsp;<a href="https://gist.github.com/rltbennett/8a750aa61d58746b3ca4531b3ca3d0db">https://gist.github.com/rltbennett/8a750aa61d58746b3ca4531b3ca3d0db</a>&nbsp;. Happy coding. (Disclaimer: barely tested.)</div><div><br></div><div><br>On May 30, 2017, at 11:27 AM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>On May 30, 2017, at 03:25, Pavol Vaskovic &lt;<a href="mailto:pali@pali.sk">pali@pali.sk</a>&gt; wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><span class="gmail-im" style="font-size:12.8px">On Tue, May 30, 2017 at 7:51 AM, David Sweeris&nbsp;<span dir="ltr">&lt;<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>&gt;</span>&nbsp;wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><span class="gmail-m_4057504060529073430gmail-"><div><br></div><div>`(Int, Int, Int, Int)` isn't *that* horrible compared to "[Int x 4]", but would you want to replace "[Int8 x 10000]" with the multipage-long tuple equivalent?</div></span></div></blockquote><div><br></div></span><div style="font-size:12.8px">😳</div><div style="font-size:12.8px">It would be really helpful to my understanding, if you spoke about a practical use case. This reads as a contrived counterexample to me…</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">If your type really has 10 000 values in it, why does it have to be static, why doesn't normal Array fit the bill?</div></div></div>
</blockquote><br><div>Sure, I meant it as an example of how unwieldy large tuples can be. Even medium ones, really. Tuples are great for bundling a few values, but much more than that any they become annoying to work with because there's no easy way to iterate through them. As a more realistic example, what if you want a stack-allocated 256-element buffer (which is a real possibility since statically-allocated C arrays are imported as tuples)? You have to manually keep track of i, because you have to hard-code which element you're addressing ("buf.0", "buf.1", etc), rather than being able to look it up directly from an index variable like, well, an array ("buf[i]").</div><div><br></div><div>Plus the fact that they can't conform to protocols really limits their usefulness in filling the role of a "normal" type. For instance, even though you could easily create the normal, 64-bit hash value from an instance of a `(Int32, Int32)` simply by concatenating the two elements' bits, you can't create a `Dictionary&lt;(Int32, Int32), SomeType&gt;` because there's no mechanism to get `(Int, Int)` to conform to Dictionary's `Hashable` requirement.</div><div><br></div><div>Could both of these features get added to Tuples? From a technically PoV, sure, and it's been discussed in previous threads. IMHO we'd get more benefit out of adding support for <span style="background-color: rgba(255, 255, 255, 0);">variadic generic parameters and&nbsp;</span>using literal values as generic parameters (both of which have also been previously discussed).</div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">But it's all out of scope until after Swift 4 comes out, because none of this affects ABI or source-code compatibility.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">- Dave Sweeris</span></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></body></html>