Do you always add a trailing comma?

You could just as easily separate using whitespace and disambiguate via parenthesis as well.

But still, this is not the only time this pattern has popped up (and a trailing comma I know was accepted in at least fortran (and later modula-3, which also had an optional leading | too) back when I was a child, so it’s quite a few decades old pattern at this point). One big thing is semicolons. In just about any older language that use a semicolon as a statement separator (*cough*C*cough*, and erlang uses semicolons too!) they did not allow trailing semicolons. Eventually C when standardized accepted the extra odd semicolon without giving you a syntax error (it just ignored it until finally the standardization required it).

Thus following the idea that ‘because they separate items’ then there should be no trailing comma also states that ‘because they separate statements’ then there should be no trailing semicolons. Do you subscribe to this as well or do you think it is special cased for some reason in a way that lists are not? :slight_smile:

Exactly this. This is why the trailing semicolon was eventually accepted as ‘human noise’ by most languages (not all, look at most ML languages!), because it helps the human even though it is noise to the compiler.

6 Likes