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
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
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
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39247 209
New
crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
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
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
griffinbyatt
Sobelow Sobelow is a security-focused static analysis tool for the Phoenix framework. For security researchers, it is a useful tool for g...
New

Other popular topics Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31107 143
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement