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

Nicolas Fezans nicolas.fezans at gmail.com
Mon May 29 16:39:41 CDT 2017

On Mon 29. May 2017 at 20:57, David Sweeris via swift-evolution <
swift-evolution at swift.org> wrote:

> > 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).

I have not followed all previous discussions on this (so sorry if it was
already proposed and/or discussed) but from the point of view of the
"standard mathematics writing", it seems to me that it should rather be
[Int^4] .

Indeed the three dimensional space built by combining the set of real
numbers R is noted R^3 or alternatively RxRxR (but for larger dimensions
you certainly do not want this writing!)

Strictly speaking  Int^4  would be mathematically speaking more correct but
 [Int^4]  has the advantage of making clear that this is indeed an array.

There are many aspects in the initial proposal that certainly need a more
expert eye than mine. I have one question though. It seems to me that the
constant expressions as known as constexpr in C++11 would be allowed as
well. Is that right? If yes, are there any differences in the proposal to
what is allowed in C++11?


> - Dave Sweeris
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170529/d75adfe2/attachment.html>

More information about the swift-evolution mailing list