Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Would this be considered legal?

  [ [1,2], ["a", "b"] ]


I wondered the same thing. "No, you can't mix data types, that's stupid" leaves it ambiguous.

If you parse the outer array as just "array of arrays" (as each element is an array), you're not "mixing". But if we're supposed to be parsing it as "arrays of arrays of _type_", then we are mixing.


This has now been clarified - it is legal


Which I find to be quite odd [1]. Data types in `TOML` can be mixed at the level of the hash table. Arrays ought to be homogeneous.

[1] - https://github.com/mojombo/toml/issues/28


The README says not to mix data types because "that's stupid" (which I don't know if I agree with); but I don't know if that answers your question.

You have an array of array, which at that level, satisfies the spec. The children individually keep types contained.

That said, I'm going to assume the intent is to not allow that.


Would it be okay to understand arrays as integer indexed keys?

For example, wouldn't that mean something like:

  array = [ [1,2], ["a", "b"] ]
Be the same as this:

  [array]
  0 = [1,2]
  1 = ["a", "b"]


It's unspecified, I guess, but if you want to read into the spirit of it, which is to make it trivially-supportable by type-nazi languages such as haskell, you either get a [[Int]] or a [[String]].


I don't know how much it is going to help as you're going to have to wrap the values anyway to get a Map with heterogeneous values.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: