[swift-evolution] [Pitch] New Version of Array Proposal

Daryle Walker darylew at mac.com
Sat Jul 22 14:41:48 CDT 2017


It’s at <https://gist.github.com/CTMacUser/cfffa526b971d0e1f3a079f53c6819bb <https://gist.github.com/CTMacUser/cfffa526b971d0e1f3a079f53c6819bb>>.

* Try to clarify that fixed-size arrays are a new kind of compound type, not a (ridiculously magical) library generic type.
* Change the separator between the bounds and element type from a colon to a semicolon.
* Specify that violating the bounds of an array during indexing is a run-time error.
* Reword how the mapping of static-indexing elements for multi-dimensional arrays works.
* Completely redo array values/literals. A literal for a fixed-size array always includes a semicolon, which separates the bounds from the values. (The separator in FSA types was changed to a semicolon to match.) A value can be a plain expression or a dictionary expression where the right side of the colon is the value and the left side is the index of the target element or “default” for all un-targeted elements. The left side can also be “func”, with the right side being an initialization closure.
* Move the “Reshaping Arrays” section and add an example.
* Right now, deterministic initialization is unchanged, so an initializing loop has to be changed to initializing the array with a function term, moving the loop to the closure.
* Remove the “parallel” declaration attribute. Add a future note about it and the “fragmentary” attribute.
* Change the for-loop example to conform to deterministic initialization. Reword how the flattening buffer functions work.
* Add examples to element-wise casting.
* Reword tuple conversion section, and add an example.
* Reword various vector-mode attribute sections. Note that there need to be two ABI additions for FSA, one for non-vectorized FSAs and one for vectorized FSAs. These two kinds of arrays need conversion functions at our (i.e. the ABI) level, but are transparent for the user.

    let v1: @vector [3; Int] = [; 1, 3, 5]
    let v2: [3; Int] = v1  // Not a type-mismatch error

* Due to FSA’s literals including the bounds, or using automatic bounds mode, array-placeholder syntax is not longer needed for type annotations and has been removed.
* Renamed “nestings” to “layers”.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170722/3675fa6c/attachment.html>


More information about the swift-evolution mailing list