Description
Creating a new issue for this because the history of this discussion is spread among multiple old (and now-closed) issues, and it's not at all clear which one should be used to re-open the discussion.
The TOML spec currently (2018-08-02) says that data types may not be mixed inside an array, but if the array contains nested sub-arrays then mixing data types is allowed. The example given is:
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
In #28 (comment), the comment was made that strongly-typed languages like Haskell are going to have a very difficult time mapping arr5
to a native data structure, because of the mixing of types in the inner arrays. That is, arr5
is an array that contains two different types: "array of ints" and "array of strings", and in Haskell those two data types are completely different and can't be combined in the same collection: arr5 is neither an "array of arrays of ints" nor an "array of arrays of strings" and is thus invalid.
After some discussion, @mojombo decided to forbid mixing data types in arrays, and moved the [ [ 1, 2 ], ["a", "b", "c"] ]
example to the "things that are not allowed" section of the spec. He created #154 for this, which also included adding a syntax for tuples. The discussion on #154 went on for some time, with a lot of back-and-forth between @dahu (who wanted to allow heterogenous arrays) and @BurntSushi (who was in favor of keeping arrays homogenous and forbidding arrays like [ [ 1, 2 ], ["a", "b", "c"] ]
).
In the end, #154 ended up being closed in favor of #235 (motivation found in #219). But what was lost in the move from #154 to #219 was the decision about homogenous arrays. #154 updated the spec to forbid [ [ 1, 2 ], ["a", "b", "c"] ]
, but #219 did not.
So despite the fact that both @mojombo and @BurntSushi appear to have been in favor of forbidding [ [ 1, 2 ], ["a", "b", "c"] ]
, the spec still allows that mixing today. This has caused some confusion (see #28 (comment) for example), which is why I think the discussion needs to be re-opened.
Is [ [ 1, 2 ], ["a", "b", "c"] ]
legal syntax or not?
The consensus of the TOML maintaners in those comments appears to have been to forbid that mixed array, but that part of the spec change got lost in the move from one PR to another. Was that intentional, and a reversal of the previous decision? Or was the intention always to forbid mixed arrays, but the spec change just fell through the cracks?