#On obvious and minimal TOML syntax
1 messages Β· Page 1 of 1 (latest)
As one of the peole with their name on the language spec, I'm curious!
On obvious and minimal TOML syntax
arrays of tables was the big one
i can do [[products]] multiple times, but not [fruit] multiple times, for example.
that's my favorite feature π
what do you like about it?
Personally allowing [[ ]] multiple times is a good feature, I wish itβs more consistent in the other direction (i.e. allowing to βreopenβ a section)
an array of maps is a common data structure, with common syntax. I don't see the advantage of doing it this way. you can do arrays of arrays in TOML with one assignment; you can do a table as one assignment; why can't i do array of tables as one assignment?
you can too but it can be super verbose
I have seen that plugins for TOML had partially supported JSON schema. Could that be in the spec one day?
if i can just write a = [{..}, {...}] and spread it onto multiple lines, then that's what I'll use π I must have missed that in the spec. There's a lot of text about the other syntax.
you might rethink that when you have to scroll horizontally π
i can spread it onto multiple lines, no?
inline tables can be on their own line yes but not broken further
but an array can be split over lines? why the difference?
If the inline table has superlong contents such as hash values..
valid:
a = [
{...},
{...},
]
invalid:
a = [
{
...
},
{
...
},
]
why?
line breaks are not allowed inside an inline table
the philosophy of toml
you're just repeating the rule. I'm trying to understand a reason. this is non-obvious.
I mean that's just how it is, like json is a subset of yaml. why is json limited to json?
Because that might lead to indentation chaos, which is strongly against the philosophy of TOML?
but multi-nested arrays could be indentation chaos.
can we at least agree the difference is non-obvious?
Nested arrays are rather rare, but yeah, that seems a little bit inconsistent across the spec
no, what you're asking I think is why toml doesn't allow full json
In TOML syntax the indentations are optional, so a repeating array of table would be more readable than a nested array of inline-tables, if indentless
no, i'm asking why arrays are so different than tables.
but if want nested arrays, i have to use the difficult-to-read syntax then? I can't do [[array]] to make nested arrays.
Yeah, but array of tables are more common than nested arrays, I guess that is why TOML treats them specially
it's just what Tom chose π easier for many use cases
"specially". i'd prefer a more uniform syntax
I really dislike the no linebreaks or trailing comma in inline tables rule. It's not at all obvious to the user, and seems like an arbitrary restriction when arrays do support it. A user (not a library author) can't do the "obvious" thing when an inline table gets too big. π¦
I believe it's a restriction to try to force non-inline tables to be used - one way to do things. But that's not always natural, and something requiring extra experience for people writing TOML, rather than a restriction on the developers designing a TOML configuration.
I also really wish a few more characters were supported in headings (like +, I want to have [a.b.dict+] indicate adding rather than overwriting, currently would have to surround in "'s.
I also would really like some sort of null/None value. I have a lot of three-way toggles (force on, force off, leave default) and things like that. Also would be an alternate solution for the above + issue - I could have ENVVAR=None remove a previously set envvar, but there's no None/null/nil.
That's not part of Obvious or Minimal, though I'd say it would be obvious if there was one. π
I for one would also find null support to be incredibly useful in the applications I use TOML. To be fair, if timestamp support is considered Obvious and Minimal (which, IMO, ut isn't) I then certainly so is null.
Does TOML support includes? (I can't check atm). If not, that would be a nice feature
Not natively, though you could do it with preprocessing or postprocessing. Typically I do that sort of thing at the Python level when I'm transforming the ingeted TOML into a more useful data structure (dataclass, pydantic, custom classes, etc.)
One of the things I like about action YAMLs (e.g. .gitlab-ci.yaml) is the ability to include yaml files via URL. So like I can put all the common stuff in a git repo and include it from all my other CI yaml files, so the latter only need a few additional lines (like variable definitions). It might also be cool to have like a config.d/ directory with bits and pieces of your pyproject.toml file. As more tools support that, it can grow pretty large and be difficult to navigate around it, even with syntax highlighting.
that isn't YAML itself but a feature built atop, no?