I'm thinking of reverting to the previous {} and [] syntax for data literals.
Although using [] for all data literals was a neat idea and unambiguous with indexing,
it's easier to visually distinguish list data from record data if the delimiters are different.
It's also easier to visually separate an initializing type from the payload:
T[a: 123] vs [T a: 123].
It get's worse if T is a generic expansion or an array-like type for eg: [[]T 1, 2, 3]
Although it could be avoided with inference var a []T = [1, 2, 3],
it's better to allow an idiomatic rhs initializer: var a = []T[1, 2, 3]
This also means the empty record literal doesn't need special syntax. Previously [:], would change to {}.
Some other awkward cases with the current syntax:
Record literal inside array literal: [[a: 123]]
Declaring record members in multiple lines:
I'm thinking of reverting to the previous
{}
and[]
syntax for data literals. Although using[]
for all data literals was a neat idea and unambiguous with indexing, it's easier to visually distinguish list data from record data if the delimiters are different.It's also easier to visually separate an initializing type from the payload:
T[a: 123]
vs[T a: 123]
.It get's worse if
T
is a generic expansion or an array-like type for eg:[[]T 1, 2, 3]
Although it could be avoided with inferencevar a []T = [1, 2, 3]
, it's better to allow an idiomatic rhs initializer:var a = []T[1, 2, 3]
This also means the empty record literal doesn't need special syntax. Previously[:]
, would change to{}
.Some other awkward cases with the current syntax: Record literal inside array literal:
[[a: 123]]
Declaring record members in multiple lines: