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

Change the language grammar to allow a trailing comma in "import" selectors #4986

Closed
scabug opened this issue Sep 10, 2011 · 16 comments

Comments

@scabug
Copy link

commented Sep 10, 2011

Change the grammar for ImportSelectors to allow a trailing comma. These will facilitate generation by tools and allow easier sorting of the values.

@scabug

This comment has been minimized.

Copy link
Author

commented Sep 10, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4986?orig=1
Reporter: G. Ralph Kuntz, MD (grkuntzmd)
Affected Versions: 2.9.1

@scabug

This comment has been minimized.

Copy link
Author

commented Oct 29, 2011

@paulp said:
Boy, I'd like trailing commas to work everywhere. So much suffering could be alleviated.

@scabug

This comment has been minimized.

Copy link
Author

commented Nov 3, 2011

Benoit Sigoure (tsuna) said:
I signed up on JIRA just so I could +1 this issue. After a bit of Googling, it seems that Scala actually used to support this, but it was removed from the language.

I'm also in the code generation camp, having to deal with "output the comma except if it's for the last element" is really annoying. Granted it's simple to work around, but it's just wasted time.

@scabug

This comment has been minimized.

Copy link
Author

commented Mar 22, 2012

Mikhail Trishchenkov (kriomant) said:
I vote for this too, not for code generation, but because of settings list in SBT configuration:

settings = Seq(
  name := 'bla',
  version := 2,
  something <<= path \{ _ / "foo" \}
)

Let's comment last line:

  settings = Seq(
  name := 'bla',
  version := 2,
  //something <<= path \{ _ / "foo" \}
}

Ooops, syntax error, fix:

settings = Seq(
  name := 'bla',
  version := 2 /*,
  something <<= path \{ _ / "foo" \} */
}
  • ugly and annoying

Ok, add new line:

settings = Seq(
  name := 'bla',
  version := 2,
  something <<= path \{ _ / "foo" \}
  another := ""
}

Damn, I always forget to add comma to previous line!

@scabug

This comment has been minimized.

Copy link
Author

commented Sep 8, 2013

Erik Allik (eallik) said:

I signed up on JIRA just so I could +1 this issue.

same here.

@scabug

This comment has been minimized.

Copy link
Author

commented Oct 15, 2013

@gkossakowski said:
Unassigning and rescheduling to M7 as previous deadline was missed.

@scabug

This comment has been minimized.

Copy link
Author

commented Nov 18, 2013

Erik Allik (eallik) said (edited on Nov 18, 2013 6:48:09 PM UTC):
Does the "... in import selectors" part of the title still hold? People, including myself, seem to be wanting trailing commas to be accepted universally.

@scabug

This comment has been minimized.

Copy link
Author

commented Nov 18, 2013

G. Ralph Kuntz, MD (grkuntzmd) said (edited on Nov 18, 2013 6:56:09 PM UTC):
The more commas, the better :-). Anywhere in the grammar that treats comma as a separator should probably allow a trailing comma. It makes machine-generation of code easier.

@scabug

This comment has been minimized.

Copy link
Author

commented May 21, 2014

Chris Martin (chris-martin) said:
Trailing commas everywhere make version control diffs much happier.

.
 foo(
     one,
     two,
+    three,
 )

versus

.
 foo(
     one,
-    two
+    two,
+    three
 )
@scabug

This comment has been minimized.

Copy link
Author

commented Aug 7, 2014

Gabriel Jones (AEthyrSurfer) said:
Commit where trailing commas were deprecated:
scala/scala@e4bc488

@scabug

This comment has been minimized.

Copy link
Author

commented Aug 7, 2014

Gabriel Jones (AEthyrSurfer) said:
I think this is where trailing commas were removed altogether:
scala/scala@b3ce4c4

@scabug

This comment has been minimized.

Copy link
Author

commented Aug 7, 2014

Gabriel Jones (AEthyrSurfer) said:
Maybe we could add an allowTrailing parameter to tokenSeparated(...)?

https://github.com/scala/scala/blob/b8deaa11cba964f686e33fe416758989df0f31eb/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala#L757-L768

@scabug

This comment has been minimized.

Copy link
Author

commented Aug 7, 2014

Gabriel Jones (AEthyrSurfer) said:
Not as simple as I thought. tokenSeparated would need to know the closing token... Maybe not so hard to pass that in from the various calls to commaSeparated?

@scabug

This comment has been minimized.

Copy link
Author

commented Feb 25, 2015

Eran Medan (eranation) said:
Why was it ever removed? :) The one feature that I actually liked in Java...
Is there any pull request on this? should I try fixing it? or is someone else working on it?

@scabug

This comment has been minimized.

Copy link
Author

commented Jun 24, 2016

@scabug

This comment has been minimized.

Copy link
Author

commented Aug 11, 2016

@SethTisue said:
SIP-27 (scala/docs.scala-lang#533) proposes allowing trailing commas not only in imports, but other places as well.

@scabug scabug closed this Feb 8, 2017

@scabug scabug added this to the 2.12.2 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.