Dataphor icon indicating copy to clipboard operation
Dataphor copied to clipboard

feature - trailing commas in lists

Open duncand opened this issue 8 years ago • 0 comments

Currently D4 is strict about the format of all comma-lists such that they may only appear between list items and may not appear before the first item or after the last item.

This is a request to relax that restriction so that any number of commas may appear within a delimited comma-list, so that they exist more to disambiguate where list items start and end and don't indicate the number of items.

For example, this should be valid syntax:

table {
  row {
    42 x,
    "hello" y,
  },
  row {
    -3 x,
    "world" y,
  },
}

A key idea here is that all list items have the same format, rather than the last one having a different format due to forced lack of a trailing comma. This makes writing code manually a lot less error prone as one can easily add or reorder list items without having to make special exceptions.

A further benefit is that code generators can have simpler logic by not having to deal with exceptions of the last list item being different, and can simply put a comma after or before every list item, period.

The rules are also more consistent with semicolon-separated lists.

Examples of common languages already supporting the wider format I indicated include C# (for some kinds of comma-lists) and Perl.

Thank you in advance.

duncand avatar Jul 07 '17 07:07 duncand