[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)

Austin Zheng austinzheng at gmail.com
Fri Jan 29 12:22:28 CST 2016


I like the (Count x Type) design, but if Swift got integer generic parameters in the future is this what tuple shorthand syntax would still look like (not rhetorical, actually asking)? It would be nice to future-proof whatever design we come up with, to a reasonable extent.

Best,
Austin

> On Jan 29, 2016, at 10:00 AM, Félix Cloutier via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list