<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Just wanted to add my two-cents to this discussion, but in terms of syntax I think that the basic method for specifying size should be with some kind of type variables, like so:<br class=""><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct MyFixedArray<T, size:Int> { … }</font></div><div class=""><br class=""></div><div class="">The idea being that we can then use size as a variable anywhere within the code for MyFixedArray, but unlike other variables it is determined at compile time, so should be optimised accordingly. As with generics, setting a type variable effectively creates a variant type so for example, a MyFixedArray<Int, size:3> and a MyFixedArray<Int, size:4> would no longer be directly compatible as they may differ internally.</div><div class=""><br class=""></div><div class="">This would be useful not just for fixed arrays, but other possibly type variations as well. Ideally it should be possible to specify a default value for type variables; while this wouldn't be useful for fixed arrays, it may be useful for other type variants.</div><div class=""><br class=""></div><div class="">To better suit the specific use-case of arrays, we could also add some useful attributes or keywords, for example, reusing subscript could give us:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Monaco" class="">struct MyFixedArray<T, subscript size:Int> { … }</font></div><div class=""><font face="Monaco" class="">let foo:MyFixedArray[4] = [1, 2, 3, 4] // with T being inferred, this is a shorthand for specifying a size of 4</font></div></blockquote><font face="Monaco" class=""><br class=""></font>Type variables could also be usable with generics, like-so:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span style="font-family: Monaco;" class="">// only accept fixed arrays of same or smaller size:</span></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Monaco" class="">func myMethod<FA>(values:FA) where FA:FixedArray, FA.size <= Self.size { … } </font></div></blockquote><div class=""></div><div class=""><div class=""><br class=""></div><div class="">These are the kind of general purpose capabilities I'd like to see at some point, as the usefulness extends beyond just fixed-size arrays.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">However, on the subject of fixed-size arrays specifically, one other possibility to explore is the concept of Tuple repetition and subscripting. For example, it would be interesting if we could do things like:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var foo:(Int)[4] = 0 // Initialises four Ints, all set initially to zero</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for i in 0 ..< 4 { foo[i] = i } // values are no 0, 1, 2, 3</font></div><div class=""><br class=""></div><div class="">This can be especially interesting when you get into more complex tuples like so:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var bar:(x:Int, y:Int)[10] = (x: 0, y: 0) // Initialises 10 pairs of Ints, all initially set to zero</font></div></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for i in 0 ..< 10 { bar[i].x = i; bar[i].y = i } // here we need to use .x and .y to access the values of each pair</font></div><div class=""><br class=""></div><div class="">Of course this would have the same performance characteristics as standard tuples, but it's an interesting means for creating quick, fixed-size arrays in a flexible way. Part of the idea here is that by subscripting tuples, we avoid the need for a general subscript on all types, keeping that available for use-cases like the above.</div></body></html>