Im currently trying to adopt Toml 1.0.0rc and I'm confused about heterogenous arrays as they now allow to contain inline tables.
Lets assume you have the following toml:
x = [{e = 1}]
Is that TOML now an 'ArrayOfTables' with an inline table or an array with a value of type inline table? My parser currently would create an 'ArrayOfTables' for that.
But as soon as change the TOML to
x = [{e=1}, 2]
the data type of x needs to change to type 'Array'?
Arrays of Tables are always written as block-level elements, like so:
[[products]]
# contents of first table go here
[[products]]
# contents of second table
[[products]]
# contents of third table
What you have is an Array (one of the value types). It's always an Array, regardless of its contents. In the past, Arrays were typed (Arrays of x), now they are no longer.
Of course, when you parse TOML, both kinds of arrays may be mapped to the same datatype – say list in Python. In that case, the difference between an Array of Tables and an Array that happens to contain just Inline Tables disappears in the parsed data structure.
Arrays of Tables are always written as block-level elements, like so:
The 'Array of tables' section contains the following example
points = [ { x = 1, y = 2, z = 3 },
{ x = 7, y = 8, z = 9 },
{ x = 2, y = 4, z = 8 } ]
which should be the equivalent of
[[points]]
x=1
y=2
...
?
Then why are 'Arrays' and 'Array of Tables' described as different things in spec? IMO in the past the TomlTable itself was not classified as a 'value type' and therefore the dedicated description of the 'Array of tables' was needed. But now suddenly 1.0rc says a TomlTable is also a 'value type'?
Then why are 'Arrays' and 'Array of Tables' described as different things in spec?
Well, inline tables are fully self-contained. You can't add new keys or new subtables outside of it. You can add subtables to a [table] block and the last [[table-array-element]] block. The README has a few examples of this.