toml-lang / toml

Tom's Obvious, Minimal Language
https://toml.io
MIT License
19.42k stars 846 forks source link

Readable Array of Tables #230

Closed trans closed 10 years ago

trans commented 10 years ago

For a lot of potential use cases the array-of-tables notation doesn't work well. It's just not very readable if there are more than a few entries. So I was thinking about what the intent of these, and it seems to me they are for tables --not hash tables, but the other kind of tables we commonly use, like in a database. So it would follow, that a notation like so would do the trick:

[products]
[name]    [sku]      [color]
"Hammer"  738594937  ""
"Nail"    284758393  "gray"
"Drill"   111753345  "black"
"Saw"     023445123  "brown"
"Screw"   573512344  "silver"

Exact notation would have to be worked out. The above could work, I think, if single entry tables weren't allowed (i.e. there has to be at least two headers). That might be too restrictive though.

I think anyone will see the merit in this if they simply write out what the above looks like in the current array-of-tables notation --it takes up a whole screen.

yosymfony commented 10 years ago

I think this suggestion violates TOML's simplicity like #204. You'll have readability problems with long-columns values.

BurntSushi commented 10 years ago

I'm against this. I can appreciate that there may be some use cases where this syntax is clearer, but:

  1. It's probably pretty rare in a config file.
  2. If #219 gets fixed, the issue of it taking up the whole screen goes away.
  3. Your suggested syntax seems to introduce significant whitespace. Blech.
  4. I don't know what you mean about hash tables vs "real" tables. A table in TOML is ideally represented as a hash table. The abstraction is a map.