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

Matthew Johnson matthew at anandabits.com
Fri Jun 2 08:42:12 CDT 2017



Sent from my iPad

> On Jun 2, 2017, at 7:33 AM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> On Fri, Jun 2, 2017 at 04:28 Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>>> On May 28, 2017, at 11:37 PM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> Static-Sized Arrays
>> 
>> My preference would still be to build this from four separate features:
>> 
>> 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.
>> 
>> 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.)
>> 
>> 3. Add sugar for a tuple of N identical elements: Probably something like `4 * Int`, but opinions can vary.
>> 
>> This solution avoids adding another structural type to the language or introducing non-type generic parameters. It also addresses other needs: 1 and 2 are desirable features in their own right which address other use cases in addition to this one. And it's nicely incremental, which is always a plus.
> 
> Exactly this. The whole conversation is wildly out of scope and the critical technical details about implementation of the feature is either missing or inaccurate, but I'll chime in for future reference to say that this particular color of the shed is, in my view, the most congruent with Swift's direction.

+1

> 
>> 
>> -- 
>> Brent Royal-Gordon
>> Architechies
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170602/5e61454a/attachment.html>


More information about the swift-evolution mailing list