arcanemachine

arcanemachine

Should the Elixir formatter allow trailing commas?

I saw this topic getting some traction over on the Erlang Forums, so I want to resurrect this topic here (previous discussion here):


Should the Elixir formatter allow trailing commas?

  • Yes
  • No
0 voters

Most Liked

sabiwara

sabiwara

Elixir Core Team

I think diffs are one part of the story, but another argument is that it removes friction when re-ordering items by moving lines around as well.
Not a major issue at all, but small pain that could totally be avoided with trailing commas.

The main concern I have with trailing commas is that they are not supported in function arguments, so this might introduce some visual inconsistency perhaps. But since lists / maps have distinct ASTs, I don’t think it’s an issue in practice.

Eiji

Eiji

The removal of trailing commas in list and map (not calls) is causing trouble a bit especially when you deal with options passed to some macro generator. Think that you want to check something part by part i.e.:

[
  key1: :value1,
  key2: :value2,
  key3: :value3,
  # key4: :value4,
  # key5: :value5,
]

When you have configured your editor to format file on save then the comma would be removed after :value3. The problem is when you want to uncomment next option(s). Every time I’m doing that I need to add the comma back which is of course simple, but really unnecessary.

Removing a single character does not help at all in my opinion and in some cases it distracts people which is really bad having in mind that Elixir was built with an approach of focus on a work on the actual problem.

dimitarvp

dimitarvp

Yeah that’s my usual problem – moving stuff in a list. The auto-removal of the comma from the last element always throws a wrench in what should be a near-brainless process.

Where Next?

Popular in Discussions Top

PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Markusxmr
Since Drab has been developed for a while in the open, introducing the Liveview functionality in a way it happend appears to undermine th...
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement