You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vote-text: The following proposal has been approved but the spec needs to be updated and the implementation has to be ported from Parsers to Scanner.
7
+
vote-status: accepted
8
+
vote-text: This SIP has been Accepted, and is a part of Scala 2.12.2.
9
9
---
10
10
11
11
**By: Dale Wijnand**
@@ -25,6 +25,7 @@ vote-text: The following proposal has been approved but the spec needs to be upd
25
25
| Sep 04th 2016 | New drawback: Cross building hinderance ([#533][]) |
26
26
| Sep 12th 2016 | Remove cross building hinderance from drawbacks ([#533][]) |
27
27
| Nov 12th 2016 | Major rework: multi-line, 2 variants & spec ([#625][]) |
28
+
| Mar 14th 2017 | Final rework: multi-line, scanner level ([#731][]) |
28
29
29
30
## Motivation
30
31
@@ -77,7 +78,16 @@ Adding and removing commas also introduces unnecessary noise in diffs:
77
78
78
79
### VCS authorship attribution
79
80
80
-
Using the example above, adding a comma after `baz` also unnecessarily changed the authorship of the line.
81
+
Adding and removing commas also unnecessarily changed the authorship of the line:
82
+
83
+
~~~
84
+
^199861c (Alice Doe 2016-12-20 10:20:05 +0000 1) Seq(
85
+
^199861c (Alice Doe 2016-12-20 10:20:05 +0000 2) foo,
86
+
^199861c (Alice Doe 2016-12-20 10:20:05 +0000 3) bar,
87
+
66dddcc3 (Bob Doe 2017-01-10 11:45:10 +0000 4) baz,
88
+
66dddcc3 (Bob Doe 2017-01-10 11:45:10 +0000 5) quux
89
+
^199861c (Alice Doe 2016-12-20 10:20:05 +0000 6) )
90
+
~~~
81
91
82
92
### Simplify code generation
83
93
@@ -136,70 +146,13 @@ There are a number of different parts of the Scala grammar that are comma-separa
136
146
*`Bindings`
137
147
*`ids`, `ValDcl`, `VarDcl`, `VarDef` and `PatDef`
138
148
139
-
With this proposal I would like to present 2 variants:
140
-
141
-
1. The first variant adds trailing comma support to only multi-line `ArgumentExprs`, `Params` and `ClassParams`, which I consider to be the parts of the grammar that would most benefit from trailing commas.
142
-
143
-
2. The second variant adds trailing comma support to the whole grammar (again, only for multi-line), which means more consistency, but also supporting trailing commas in places that in practice don't really require it as much, such as `ids`.
144
-
145
-
In this proposal, only the first variant is considered: trailing comma support for `ArgumentExprs`, `Params` and `ParamClasses` for the sake of simplicity.
146
-
147
-
See below for more details on what that would mean.
Following Dr. Martin Odersky's suggestion, the proposal is that trailing commas are only supported in comma-separated elements that are enclosed by parentheses, square brackets or curly braces (`)`, `]`, and `}`, respectively).
199
150
200
151
## Implementation
201
152
202
-
The implementation of trailing commas is limited to changing Parsers.scala in the Scala compiler. An implementation of this proposal can be found at [scala/scala#5245][].
153
+
As such, the suggested implementation would be a Scanner-level implementation, in which newlines and the closing delimiters are taken into account.
154
+
155
+
Such an implementation can be found at [scala/scala#5245][].
203
156
204
157
## Drawbacks/Trade-offs
205
158
@@ -222,3 +175,4 @@ As an alternative to changing the language, there already exists today a compile
0 commit comments