[swift-evolution] Yet another fixed-size array spitball session

David Sweeris davesweeris at mac.com
Mon May 29 13:19:52 CDT 2017

> On May 29, 2017, at 01:12, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
> I agree strongly that the syntax looks awkward — imho
> var v: Vector<Int, size: 3>
> would be a much better fit than
> var v array 3 of Int
> As much as I want to have "real" arrays, I don't think we should add new keywords for them.

Yeah, a "fixed-size array" is probably the most obvious use-case for allowing literal values to be generic parameters. In fact, at that point, they'd just be another type... no special support needed, other than validating the count when assigning array literals to them.

The syntax that gained some traction last time they were seriously discussed would also be better, IMHO:
let x: [Int x 4]
or maybe it was this?
let x: [Int * 4]
Either way, it's more concise, far easier to read (IMHO), and doesn't need new keyword(s).

- Dave Sweeris

More information about the swift-evolution mailing list