Closed dapper-gh closed 2 years ago
Can you substantiate why you believe this codebase should use the oxford comma?
To quote wikipedia:
Opinions among writers and editors differ on whether to use the serial comma, and usage also differs somewhat between regional varieties of English.
Although it is optional, it prevents ambiguity ("a, b of c and d" vs. "a, b of c, and d"). Additionally, it is either optional or common in most variants of English:
British English allows constructions with or without this comma, while in American English it is common and sometimes even considered mandatory to use the comma.
I suggest you take a peek at the linked article, which shows that this cuts both ways.
Since we are also dealing with arbitrary and arbitrarily nested data structures (e.g, consider vec![vec![","], vec!["a and b", "c"]]
), an ambiguity-free data representation needs to be more complex (such as is achieved with the debug formatter). The default formatter is intended to provide a reasonable default for simple data structures.
Fair enough. The linked example ("A, a B, and C") would still be ambiguous without the comma: "I am A, a B and C." could mean that I am A, which is both a B and C, or it could mean that I am A, a B, and C (three distinct items). However, I can understand why attempting to create a perfectly unambiguous representation of arbitrary data is an impossible goal, and how not including the Oxford comma is a "reasonable default".
I will leave this issue open, in case more opinions come in. If it turns out that the users of this project significantly prefer the oxford comma, we can change it in the future.
As of ea1fce535be02755dce11e24f858381921c77808, oxford commas are available via a feature flag.
The Issue
When printing out a
Vec
, there is no Oxford comma (the comma before the "and" in a list of 3 or more items).Example
One item:
a
(correct) Two items:a and b
(correct) Three items:a, b and c
(incorrect: should bea, b, and c
) Four items:a, b, c and d
(incorrect: should bea, b, c, and d
) And so on...Affected Code
https://github.com/danielschemmel/build-info/blob/3d31efddef7bafee4098459557a18775bccce8fb/build-info-proc/src/format/value/vec.rs#L52-L69