<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>On May 30, 2017, at 03:25, Pavol Vaskovic <<a href="mailto:pali@pali.sk">pali@pali.sk</a>> 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 <span dir="ltr"><<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>></span> 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<(Int32, Int32), SomeType>` 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 </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></body></html>