[swift-evolution] Yet another fixed-size array spitball session

Tino Heth 2th at gmx.de
Fri Jun 2 05:26:16 CDT 2017

> 1. Magic tuple conformances: We already want to be able to automatically conform tuples to protocols like Equatable, Hashable, and Comparable. These can all be compiler magic; they don't have to be definable in userspace.
> 2. Conform tuples to Collection: The Element type should be the most specific common supertype of the tuple's elements. If all the elements are the same type, it would be that type. The Index and IndexDistance types should be Int.
I always see tuples as some kind of anonymous struct, and those two have much more in common than with collections — so when tuples conform to collection, structs and classes should conform as well.
I'm just not sure what to think about that idea (might be useful, but could be terrible)

> 3. Conform same-type tuples to MutableCollection: If all elements are the same type, you can also modify the values. (If their types vary in any way, however, it would not be safe to allow mutations, since you could assign the wrong type to an element.)
I think that's to confusing without much benefit in return.

> 4. Add sugar for a tuple of N identical elements: Probably something like `4 * Int`, but opinions can vary.
[small correction applied]
I strongly dislike all shortcuts that have been proposed, and think they don't pull their own weight.

For me, generics are definitely the best solution — maybe we should just declare literals to be types? ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170602/6996b78f/attachment.html>

More information about the swift-evolution mailing list