[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)
Félix Cloutier
felixcca at yahoo.ca
Fri Jan 29 12:00:54 CST 2016
> Le 29 janv. 2016 à 00:50:52, Chris Lattner <clattner at apple.com> a écrit :
>
>
>> 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.
Why will it be possible to add a subscript but not an initializer?
>> 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.
If direct element access is disallowed on homogeneous tuples, to me, it would look like a bug that you can use direct element access on a (T, U) tuple from a generic function with <T, U> parameters, but not anywhere else. But regardless, we seem to agree that homogeneous tuples shouldn't lose direct member access.
Félix
More information about the swift-evolution
mailing list