I already mentioned that I do not want to use generics syntax.
For “Int[4]” or similar: we don’t use C’s (cute) “declaration looks like use” syntax. The declaration wouldn’t spiral out, but be strictly in one direction. That means that the bracketed part would array-ize the type expression to its left. That means that “Int[4][6]” would make the widest span the extent with six elements, the reverse direction of C’s array declarations. However, dereferencing still happens in C’s order. So now it’s double confusing, unless we break Swift’s philosophy and make nested array extent order to be the same as C. Or do what I did and make the extent length precede the element type.
I kept multiple-dimension support out of immediate arrays for similar reasons. Think about “Int[5, 6]”, does that store the elements like “Int[5][6]” or “Int[6][5]”? (And is that like C’s order or my theoretical Swift reversed order?) Instead of worrying about that in quick & dirty arrays, I moved said concerns to a full declaration block syntax for arrays, and even allow overriding of row-major vs. column-major. And the immediate arrays use tuple’s “object.index” for dereference; I would have to find a way to make that work with multiple coordinates, but not for nominal arrays which can use the subscript operator. (And no, I don’t support “” on immediate arrays, since they’re supposed to model tuples (with homogenous member type), which are generally closed for extensions.)
···
On May 30, 2017, at 2:32 AM, Charlie Monroe via swift-evolution swift-evolution@swift.org wrote:
Sorry if this has been suggested before, but what is wrong with something along
let x: Int[4]
let x: Int<4>
In case of multi-dimension arrays:
let x: Int[4][4]
let x: Int[4, 4]
let x: Int<4><4>
let x: Int<4, 4>
I see small issues with each that would need to be discussed - the first would disallow subscripts on types. Subscripts currently cannot be static, at least now anyway, though. The second syntax is too close to generics, which may be confusing...
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com