Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature - trailing commas in lists #35

Open
duncand opened this issue Jul 7, 2017 · 0 comments
Open

feature - trailing commas in lists #35

duncand opened this issue Jul 7, 2017 · 0 comments

Comments

@duncand
Copy link
Contributor

duncand commented Jul 7, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant