danielschemmel / build-info

Collects build-information of your Rust crate
https://crates.io/crates/build-info
24 stars 11 forks source link

Using the Oxford Comma for Formatting Sequences #4

Closed dapper-gh closed 2 years ago

dapper-gh commented 3 years ago

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 be a, b, and c) Four items: a, b, c and d (incorrect: should be a, 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

danielschemmel commented 3 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.

dapper-gh commented 3 years ago

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.

Source

danielschemmel commented 3 years ago

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.

dapper-gh commented 3 years ago

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".

danielschemmel commented 3 years ago

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.

danielschemmel commented 2 years ago

As of ea1fce535be02755dce11e24f858381921c77808, oxford commas are available via a feature flag.