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
To avoid some ambiguity in the grammar and being able to use {} for blocks only, it's probably a good idea to change struct initializers to use the [] syntax.
The type of [] would depend on the elements provided.
Element
Kind
Resulting type
1
[]
empty tuple
()
2
[1, 2, 3]
static array
[3; int]
3
[1, 2.0, 3]
tuple
(int, double, int)
4
[b = 20]
structure
struct { b: int }
5
[1, 2, b = 20]
initializer
Initializer([2; int], struct { b: int })
6
[1, 1.5, b = 20]
initializer (jagged)
Initializer((int, double), struct { b: int })
7
[(1) = 20, (2) = 30]
initializer map
InitializerMap([2; int], [2; int])
8
[(1) = 20, (1.5) = 2.5]
initializer map (jagged)
InitializerMap((int, double), (int, double))
Coercion table
↱
1
2
3
4
5
6
7
8
1
x
x
x
x
x
x
x
x
2
x
x
3
x
4
x
x
x
5
x
x
6
x
7
x
x
8
x
Struct initialization could be done using 1-6. Array initialization could be done with 1-3.
To avoid some ambiguity in the grammar and being able to use
{}
for blocks only, it's probably a good idea to change struct initializers to use the[]
syntax.The type of
[]
would depend on the elements provided.[]
()
[1, 2, 3]
[3; int]
[1, 2.0, 3]
(int, double, int)
[b = 20]
struct { b: int }
[1, 2, b = 20]
Initializer([2; int], struct { b: int })
[1, 1.5, b = 20]
Initializer((int, double), struct { b: int })
[(1) = 20, (2) = 30]
InitializerMap([2; int], [2; int])
[(1) = 20, (1.5) = 2.5]
InitializerMap((int, double), (int, double))
Coercion table
Struct initialization could be done using 1-6. Array initialization could be done with 1-3.
The text was updated successfully, but these errors were encountered: