- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
trailing commas status
Fri, 2009-07-03, 15:44
SLS 3.2.5:
The type may also be written with a trailing comma, i.e. (T, . . . , T,).
SLS 8.1.6:
A tuple pattern ... may also be written with a trailing comma, i.e. (p
1 , . . . , p n ,).
Trailing commas are reported deprecated in 2.7.x and it looks like in
r17773 support was removed entirely:
scala> def bob(x: Any) = x match { case (1,2,) => true }
:1: error: illegal start of simple pattern
def bob(x: Any) = x match { case (1,2,) => true }
^
I can't google up any rationale for the deprecation. I agree with the
points in this thread:
http://www.nabble.com/-scala--Why-trailing-comma-is-deprecated--td222657...
Can anyone offer what was the reasoning? I don't use trailing commas
that much except when debugging, but when I do have to snip one comma
and add another it feels like purposeless busywork.
Fri, 2009-07-03, 17:07
#2
Re: trailing commas status
Trailing commas only ever seemed amusing to me, not actually useful.
I know and reject the diff argument. While the extra line of diff
output can be irritating, I don't think languages should be designed
around diff, rather the reverse.
I appreciate that if I had got used to using them I might be saying
the opposite now, but I'm quite happy to see them go, as they don't
add anything. In the modern form of speaking, they have a low
power-to-weight ratio, or torque or breakhorsepower or something.
2009/7/3 Paul Phillips :
> SLS 3.2.5:
> The type may also be written with a trailing comma, i.e. (T, . . . , T,).
>
> SLS 8.1.6:
> A tuple pattern ... may also be written with a trailing comma, i.e. (p
> 1 , . . . , p n ,).
>
> Trailing commas are reported deprecated in 2.7.x and it looks like in
> r17773 support was removed entirely:
>
> scala> def bob(x: Any) = x match { case (1,2,) => true }
> :1: error: illegal start of simple pattern
> def bob(x: Any) = x match { case (1,2,) => true }
> ^
>
> I can't google up any rationale for the deprecation. I agree with the
> points in this thread:
>
> http://www.nabble.com/-scala--Why-trailing-comma-is-deprecated--td22265798.html
>
> Can anyone offer what was the reasoning? I don't use trailing commas
> that much except when debugging, but when I do have to snip one comma
> and add another it feels like purposeless busywork.
>
> --
> Paul Phillips | The important thing here is that the music is not in
> Caged Spirit | the piano. And knowledge and edification is not in the
> Empiricist | computer. The computer is simply an instrument whose
> up hill, pi pals! | music is ideas. -- Alan Kay
>
Fri, 2009-07-03, 17:27
#3
Re: trailing commas status
On Fri, Jul 03, 2009 at 04:57:48PM +0100, Ricky Clarkson wrote:
> I know and reject the diff argument.
I had to look up what you meant by the diff argument, which I hadn't
even seen. For the record I wasn't basing this on the diff argument at
all, but on the "oops I forgot to move the comma and scalac is compiling
230 files so it'll take its sweet time before it tells me I have
busywork to do, even though it knows exactly what I mean" argument.
Lukas
On Fri, Jul 3, 2009 at 16:44, Paul Phillips <paulp@improving.org> wrote: