toml-lang / toml

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

List ability #1015

Closed Soel-Philippe closed 7 months ago

Soel-Philippe commented 7 months ago

Hello guys, appreciate your work. But why haven't you implemented row-by-row listing? I was expecting something like:

id = 
  - elem1
  - elem2
  - elem3 

while the only to do it is:

id = [elem1,elem2,elem3]

I'm reluctant of having 2K, 10K elements inline in a file, I don't feel it healthy.

By the way, I'm coming from YAML...

arp242 commented 7 months ago

TOML isn't YAML, and the syntax is different.

And it seems to me that this really isn't all that different/less awkward:

id = [
    elem1,
    elem2,
    elem3,
]
Soel-Philippe commented 7 months ago

Thanks sir for your reply.

Although TOML isn't YAML, that thing of writing 8000-width lines isn't sane to me. For what I aim to do, TOML is perfect beautifully built... When I sink a Dict (from Julia), having a 1000-elements vector at the id slot, into a file, it won't do:

id = [
  elem1,
  .
  .
  .
]

it'll just silly print the 1000-length array inline.

By the way it's just my humble opinion to require that listing ability... You guys are making multi-billion dollar apps, if you're okay with it, who am I?!

arp242 commented 7 months ago

That sounds like an issue you'll need to take up with the Julia people; maybe splitting it out over multiple lines is already possible – I don't know Julia – or maybe the encoder can be improved.

Also, adding any new syntax won't really fix or change anything for you: id = [1, 2, 3] will still be valid TOML, and many encoders will still encode it like that unless you tell them to encode it differently.

JamesParrott commented 7 months ago

It's a problem with whichever TOML library you're using, not the fundamental language syntax/grammar (which is the scope of this repo).

TOML supports arrays over multiple lines already, as Martin pointed out. The TOML language just doesn't enforce it. Some TOML writing libraries print list items line by line by default:

>>> print(tomli_w.dumps({'id': [f'elem{i}' for i in range(4)]}))
id = [
    "elem0",
    "elem1",
    "elem2",
    "elem3",
]

Is there not a TOML library for Julia that does the same?

Soel-Philippe commented 7 months ago

Yes sir,

I got you, I'll write a lil function aside to enforce multi-lines when necessary.

Thanks for your replies. Keep goin'