In all this discussion of trailing commas, there is a use-case that's not been discussed, which is whether or not a trailing comma after the last of a list of comma-separated items (typically on separate lines) makes it easier to write a program that outputs Swift code declaring that list. It does.
If such a trailing comma is going to raise a syntax error, and one writes a loop for a set of listed items that will print those listed items, one either has to special case the first item to not be preceded by a ",\n", and print all subsequent items prefixed with a ",\n"; or one has to end all items except the last with a ",\n". Either way is a pain, adds an extra test to the loop, and likely will be implemented erroneously the first time. Code that is written by other code always has a strong incentive to avoid raising any compiler error/warnings, and so tends not to be read as much by humans who might think there's a missing item after the last extra comma. How about a syntax warning/error for only those trailing commas that end a line that contains a previous comma serving the same syntactic function at the same syntactic level? Doug McKenna _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
