Naming conventions for arrays of tables #932
Replies: 4 comments 7 replies
-
The more important question here of course is whether or not we should include Pluto in the list of planets. Singular seems nicer in the TOML, but:
So in the code plural looks (much) better, IMO, so I'd choose that. |
Beta Was this translation helpful? Give feedback.
-
@ChristianSi I much prefer the plural naming convention. The name of the array would be A case could be made for singular naming if just one element is expected. But it's still decoded as an array. An array of a single table, but still an array. If you don't mind reading Another case, coming from the database world, is that you give the array a singular name for the sake of convenience. You may have multiple database tables with plural names, so forcing singular names on your collections cuts down on the clutter of seeing "s" and "es" everywhere. But practically every dialect of SQL provides for table synonyms to keep that clutter out of your queries. With arrays of tables, I doubt that you would be juggling so many different kinds of them in a single TOML document that the same argument would apply. Maybe those plural forms are visual clutter in TOML, and that So I personally see no compelling reason to use singular names for arrays. |
Beta Was this translation helpful? Give feedback.
-
Plural style for me. It's consistent with how I would name a collection in any other context. |
Beta Was this translation helpful? Give feedback.
-
You all think like programmers, not like TOML file writers. I'd argue that one should take the user perspective first, and put the programmer's way of thinking behind. For any general-purpose scenario, people will spend way more writing and editing TOML files that on the program code used to process them. So "How does it look and feel in the TOML file?" should be the relevant question. |
Beta Was this translation helpful? Give feedback.
-
Consider the following array of tables, using the "plural" naming convention that's commonly used in the spec:
While here is the same file in "singular" convention:
Everybody: which convention do you prefer? For me it's clear that I prefer the "singular" convention since array each element describes a single item. Hence it seems strange (to me) having a plural "section header" followed by a single item.
Therefore I consistently use the singular convention in my TOML files. I wonder how others here see this? Do you prefer singular or plural?
If many prefer singular, it might be worth considering switching to singular style for the examples used by the spec. Since though the spec doesn't give any explicit naming tips (and it shouldn't), many will tend to follow the example shown there.
Beta Was this translation helpful? Give feedback.
All reactions