Re: Semicolon wrangling (was Re: [friam] Minutes)

Lex Spoon <[email protected]> Sun, 21 Oct 2012 01:14:03 -0400
Newsgroups gmane.comp.lang.e.general
Message-ID <CALM2Sna-X9KmM1HGvhbZ6o5L_aW7rN7W-ZCa727hxKaoM9Gq=w@mail.gmail.com>
On Fri, Oct 19, 2012 at 10:10 PM, William ML Leslie
<[email protected]> wrote:
> Some languages do support this in function arguments, I don't think it
> is such a bad thing.  It means one less thing to have to worry about
> when generating code from a language that doesn't have a sensible
> reduce/join, or generating code from within emacs (it would be
> /really/ useful in SQL).

Python is one such.  In Python, for most any form of sequence in the
syntax, you can optionally add an extra separator at the end of the
list. This rule includes arguments to function calls; f(x,y,z,) in is
the same as f(x,y,z).

The trailing commas help with code generation, and also for humans
editing code. For example, consider the following code in Python or
JavaScript:

names = [
  "Fred",
  "Wilma",
  "Bam Bam",
]

The trailing comma makes the code more regular, which makes it easier
to edit. For example, you can swap any two lines in the list without
having to fix up the commas afterwards.

Once you allow a trailing comma for lists, it is hard to resist
allowing it for function calls (Python only):

set_names(
  "Fred",
  "Wilma",
  "Bam Bam",
)

It gets worse if you have nesting. Consider the following example of
JSON, which does not permit trailing commas:

{
  "name": "Fred",
  "child0": {
    "name": "Fred, Jr."
  },
  "child1": {
    "name": "Mary"
  }
}

It would be easier to edit code like the above if you were allowed to
put a comma at the end of every line. Or better yet, none of them.

Lex