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

Why trailing comma is deprecated?

3 replies
Stepan Koltsov
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.

Why trailing comma in varargs is deprecated? It is handy:

===
val collations = Map(
"cp1256" -> "cp1256_general_ci",
"cp1257" -> "cp1257_general_ci",
...
"geostd8" -> "geostd8_general_ci",
"cp932" -> "cp932_japanese_ci",
"eucjpms" -> "eucjpms_japanese_ci",
)
===

Such lists can be long, and can change over time. It is harder to
maintain such lists, when trailing comma is not permitted:

— I have to remeber that I cannot just drop a line, and I cannot just
add a line — I have to write commas.
— Diffs contain unnecessary information when just one entry added:

===
"cp932" -> "cp932_japanese_ci",
- "eucjpms" -> "eucjpms_japanese_ci"
+ "eucjpms" -> "eucjpms_japanese_ci",
+ "armscii8" -> "armscii8_general_ci"
)
===

S.

Jon Buffington
Joined: 2009-02-28,
User offline. Last seen 42 years 45 weeks ago.
Re: Why trailing comma is deprecated?

On Feb 28, 2009, at 2:24 PM, Stepan Koltsov wrote:

> Why trailing comma in varargs is deprecated? It is handy:
>
> ===
> val collations = Map(
> "cp1256" -> "cp1256_general_ci",
> "cp1257" -> "cp1257_general_ci",
> ...
> "geostd8" -> "geostd8_general_ci",
> "cp932" -> "cp932_japanese_ci",
> "eucjpms" -> "eucjpms_japanese_ci",
> )
> ===
>
> Such lists can be long, and can change over time. It is harder to
> maintain such lists, when trailing comma is not permitted:
>
> — I have to remeber that I cannot just drop a line, and I cannot just
> add a line — I have to write commas.
> — Diffs contain unnecessary information when just one entry added:
>
> ===
> "cp932" -> "cp932_japanese_ci",
> - "eucjpms" -> "eucjpms_japanese_ci"
> + "eucjpms" -> "eucjpms_japanese_ci",
> + "armscii8" -> "armscii8_general_ci"
> )
> ===

If you are adding to the tail of the list, I find the following
structure helpful:

val collations = Map( "cp1256" -> "cp1256_general_ci"
, "cp1257" -> "cp1257_general_ci"
...
, "geostd8" -> "geostd8_general_ci"
, "cp932" -> "cp932_japanese_ci"
, "eucjpms" -> "eucjpms_japanese_ci"
)

- Jon

>
>
> S.

Stepan Koltsov
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Why trailing comma is deprecated?

On Sat, Feb 28, 2009 at 22:39, Jon Buffington wrote:
> On Feb 28, 2009, at 2:24 PM, Stepan Koltsov wrote:
>
>> Why trailing comma in varargs is deprecated? It is handy:
>>
>> ===
>> val collations = Map(
>>       "cp1256"   -> "cp1256_general_ci",
>>       "cp1257"   -> "cp1257_general_ci",
>>       ...
>>       "geostd8"  -> "geostd8_general_ci",
>>       "cp932"    -> "cp932_japanese_ci",
>>       "eucjpms"  -> "eucjpms_japanese_ci",
>> )
...
> If you are adding to the tail of the list, I find the following structure
> helpful:
>
> val collations = Map( "cp1256"   -> "cp1256_general_ci"
>                    , "cp1257"   -> "cp1257_general_ci"
>                    ...
>                    , "geostd8"  -> "geostd8_general_ci"
>                    , "cp932"    -> "cp932_japanese_ci"
>                    , "eucjpms"  -> "eucjpms_japanese_ci"
>                    )

Unfortunately, it does not allow working with first element :)

S.

robey
Joined: 2008-12-24,
User offline. Last seen 1 year 21 weeks ago.
Re: Why trailing comma is deprecated?
On Sat, Feb 28, 2009 at 1:54 PM, Stepan Koltsov <stepan.koltsov@gmail.com> wrote:
On Sat, Feb 28, 2009 at 22:39, Jon Buffington <lists@jon.buffington.name> wrote:
> On Feb 28, 2009, at 2:24 PM, Stepan Koltsov wrote:
>
>> Why trailing comma in varargs is deprecated? It is handy:
>>
>> ===
>> val collations = Map(
>>       "cp1256"   -> "cp1256_general_ci",
>>       "cp1257"   -> "cp1257_general_ci",
>>       ...
>>       "geostd8"  -> "geostd8_general_ci",
>>       "cp932"    -> "cp932_japanese_ci",
>>       "eucjpms"  -> "eucjpms_japanese_ci",
>> )

Just ran across this thread while cleaning up my mail, and wanted to make sure:

This feature is *not* being deprecated anymore, right? The warning message in 2.7.3 is kind of annoying, since, as others pointed out, trailing commas are allowed in most other languages, and are used all over the place.

robey


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