Suggestion for alternate array syntax #1060
Replies: 1 comment 1 reply
-
What exactly makes YAML easier to follow than TOML in this example? I assumed that you are referring to lack of verbosity (commas), however, further down you mention additional verbosity as desirable. 😕 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The one issue I have with TOML is the syntax for arrays of scalar values. It's great for a small array (up to 3 or 4 items), but it gets awkward, in my opinion, when it gets larger than that.
For example, an array of many strings is actually more difficult to follow in TOML than it is in YAML.
I have one project that I use YAML for the configuration file because of this, although, I'd much rather use TOML.
In this file, I have something like this:
If I were to use TOML, that would be:
For this example,
config.extensions
is just as easy in yaml as it is in toml. In fact, due to the lack of commas, it's a tiny bit easier in YAML. And since I have multiple fields like this in this config file, it's just easier for me to use YAML for this particular use-case. Even though, there are some other benefits to TOML that I'd like to use.I wish there was an alternate syntax for stuff like this, although I'm not certain what the best option would be. Here are two thoughts I have:
First is to use
[]
, so that it looks like appending to an array in PHP.My example would look like this:
Another option would be to use a special character with dot notation. I suggest a hash. So, it would look like this:
Obviously, both of these options are more verbose than the current syntax, and that's actually my intention. Just like there are two syntaxes for tables, and two different syntaxes for arrays of tables, I think having a more verbose verbose syntax (to make it more explicit) would be a good idea.
There might be better options, but I think something like this would be good. Someway to mirror the way that an array of tables has two different syntaxes.
But both of the options I suggested are currently invalid, so there wouldn't be an incompatibility with current features.
Beta Was this translation helpful? Give feedback.
All reactions