This page is no longer maintained — Please continue to the home page at www.scala-lang.org

trailing commas status

3 replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

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.

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: trailing commas status
they've been deprecated and are no longer in trunk.i already changed the spec accordingly. it's just not checked in yet.

Lukas
On Fri, Jul 3, 2009 at 16:44, Paul Phillips <paulp@improving.org> wrote:
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 }
<console>: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

Ricky Clarkson
Joined: 2008-12-19,
User offline. Last seen 3 years 2 weeks ago.
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
>

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
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.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland