Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6407472

Allow trailing comma in all places where comma is used as a separator

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P5 P5
    • None
    • 6
    • specification
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      The array initializer syntax allows an optional trailing comma which is ignored. Here is the grammar from JLS:

      ArrayInitializer:
      { VariableInitializersopt ,opt }

      See bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=1204519

      Allow similar optional trailing comma in all the places where comma is used as a separator. The places I can think of are:

      - implements clause interface list
      - throws clause exception list
      - method parameters
      - method call parameters

      I know this is a compatible change to the JLS. However the impact may be relatively small (except for language tools) as the comma is optional and is ignored.

      JUSTIFICATION :
      This is an ease of use issue for me. I wish I had brought it up during the Tiger days when the ease of use changes were made to the language.

      This is useful when quickly reordering items in comma separated lists. I find myself deleting and adding commas when reordering the parameters in a method declaration or method call.

      I have seen a lot of special code in many code generation tools when dealing with last and non last or first and non first items in the comma separated list.

      I find it easy to work with array initializers due to the support for optional trailing comma.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The optional trailing comma is supported in cases stated in the description and is ignored.
      ACTUAL -
      The trailing comma is not allowed in case stated in the description.

            abuckley Alex Buckley
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: