You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0483-inline-array-sugar.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ We propose the introduction of type sugar for the `InlineArray` type, providing
19
19
let fiveIntegers: InlineArray<5, Int> = .init(repeating: 99)
20
20
```
21
21
22
-
Declaring this type is more cumbersome than its equivalent dyanmicaly-sized array, which has sugar for the type syntax:
22
+
Declaring this type is more cumbersome than its equivalent dynamically-sized array, which has sugar for the type syntax:
23
23
24
24
```
25
25
let fiveIntegers: [Int] = .init(repeating: 99, count: 5)
@@ -45,7 +45,7 @@ Note that although it is used in the manner of an operator, `x` here serves more
45
45
46
46
## Detailed design
47
47
48
-
The new syntax consists of the value for the integer generic paramter and the type of the element generic paramter, separated by `x`.
48
+
The new syntax consists of the value for the integer generic parameter and the type of the element generic parameter, separated by `x`.
49
49
50
50
This will be added to the grammar alongside the current type sugar:
51
51
@@ -124,12 +124,12 @@ For multi-dimensional arrays, `[5 x [5 x Int]]` could be flattened to `[5 x 5 x
124
124
The most obvious alternative here is the choice of separator. Other options include:
125
125
126
126
-`[5 * Int]`, using the standard ASCII symbol for multiplication.
127
-
-`[5 ⨉ Int]`, the Unicode n-ary times operator. This looks nice but is impactical as not keyboard-accessible.
127
+
-`[5 ⨉ Int]`, the Unicode n-ary times operator. This looks nice but is impractical as not keyboard-accessible.
128
128
-`[5; Int]` is what Rust uses, but appears to have little association with "times" or "many". Similarly other arbitrary punctuation e.g. `,` or `/` or `#`.
129
129
-`[5 of Int]` is more verbose than `x` but could be considered more clear. It has the upside or downside, depending on your preference, of being almost, but not quite, grammatical.
130
130
-`:` is of course ruled out as it is used for dictionary literals.
131
131
132
-
Note that `*` is an existing operator, and may lead to ambiguity in fuure when expressions can be used to determine the size: `[5 * N * Int]`. `x` is clearer in this case: `[5 * N x Int]`. It also avoids parsing ambiguity, as the grammar does not allow two identifiers in succession. But it would be less clear if `x` also appeared as an identifier: `[5 * x x Int]` (which is not yet permitted but may be in future use cases).
132
+
Note that `*` is an existing operator, and may lead to ambiguity in future when expressions can be used to determine the size: `[5 * N * Int]`. `x` is clearer in this case: `[5 * N x Int]`. It also avoids parsing ambiguity, as the grammar does not allow two identifiers in succession. But it would be less clear if `x` also appeared as an identifier: `[5 * x x Int]` (which is not yet permitted but may be in future use cases).
133
133
134
134
This becomes more important if the future direction of a value equivalent is pursued. `[2 * 2 * 2]` could be interpreted as `[2, 2, 2, 2]`, `[4, 4,]`, or `[8]`.
135
135
@@ -152,7 +152,7 @@ The order of size first, then type is determined by the ordering of the unsugare
152
152
153
153
### Whitespace around the delimeter
154
154
155
-
In theory, when using integer literals or `_` the whitespace could be omitted (`[5x_]` is unabiguously`[5 x _]`). However, special casing allowing whitespace omission is not desirable.
155
+
In theory, when using integer literals or `_` the whitespace could be omitted (`[5x_]` is unambiguously`[5 x _]`). However, special casing allowing whitespace omission is not desirable.
0 commit comments