[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)
Dave Abrahams
dabrahams at apple.com
Fri Jan 29 15:11:21 CST 2016
on Thu Jan 28 2016, Chris Lattner <swift-evolution at swift.org> wrote:
>> On Jan 28, 2016, at 9:41 PM, Félix Cloutier <felixcca at yahoo.ca> wrote:
>>
>> I think that (4 x Int) needs to be syntax sugar for (Int, Int, Int,
>> Int). Not having them the same would introduce awkward cases into
>> the language.
>
> Agreed. This means that:
>
> let values: (4 x Int)(repeatedValue: 0) // Is this possible?
>
> will not be possible.
I think this avenue leaves some really crucial use-cases on the table,
e.g. implementing bounded-size dynamically-growable arrays. There
should, at the very least, be a way to declare an array of uninitialized
suitably-aligned storage for any type. And I think we'd also need
non-type generic parameters to complete the picture.
>> Because of that, I also think that forcing people to use the
>> subscript would have some awkward consequences. What if I have a
>> func<T, U> that uses a (T, U) tuple and both T and U happen to be
>> the same type?
>
> I don’t understand this concern.
>
>> So I think that tuples whose elements all have the same type should
>> get a subscript but shouldn't lose direct field access.
>
> Agreed.
>
> -Chris
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
--
-Dave
More information about the swift-evolution
mailing list