Showing Posts 50 to 41

augnustin

augnustin

I think people who aren’t supportive with trailing comma are the ones who never used it.

Eg. @WolfDan:

Hum it seems useless hahahaha

You completely discredited yourself by not being aware of what the topic was about. :stuck_out_tongue:

IMHO:

In addition to the git diff argument, a few haven’t been mentioned:

  • so many mistakes would be avoided: when you duplicate a line, or invert two lines, and don’t see that one of those doesn’t have the comma, it is another 5 seconds lost
  • in general, when writing enumeration in code, it is much more comfortable not to have to think is this the last item of my list? and put a comma instinctively

I understand that this is not compatible with optional parenthesis, which, even though I am not a big fan of it, makes functional code clearer (since functional means that there will be many function calls, hence many parentheses).

But I think it is worth the price.

Removing optional parenthesis would encourage us to write less nested code, which is a positive external effect of it.

Cheers

OvermindDL1

OvermindDL1

Huh, this same issue got discussed on the ReasonML repo lately too, they gave a good reason (this is the owner of ReasonML speaking):

https://github.com/facebook/reason/pull/1775#issuecomment-359957416

I’ve found that trailing commas help with a bit of paren-fatigue as well, because it helps you distinguish closing parens for arguments/tuples/variants from parens whose only purpose is to resolve precedence - at least in the case where things break onto multiple lines. It’s a small help, but it is a help.

Deithrian

Deithrian

Idk.
In my world, function arguments indicate only what the function accepts.
I would never manipulate data there, because that’s supposed to happen in the function body.
I feel that if manipulation happens in the function arguments, as well as in the function body, there’s now two places where bugs can happen.
Combined with SRP, my arguments never get long. ¯\ (ツ) /¯

def function_name(data1, data2 ,data3) do
“do stuff with data1,2,3”
end

ryanwinchester

ryanwinchester OP

It might not be that you have a lot of arguments, but that the arguments themselves are long. for example with pattern matching

def some_user_company_thing(%User{} = user, %Company{} = company, params \\ %{}) do
  #
end 

even just that starts getting long, imagine adding a guard

def some_user_company_thing(
  %User{} = user,
  %Company{} = company,
  params \\ %{},
) when something do
  # ¯\_(ツ)_/¯
end 

maybe i’m weird but i prefer to see things like that than start horizontal scrolling in my code.

also, i don’t care a whole lot about the trailing comma, it’s helpful but not a huge pain point, it was mostly a tongue-in-cheek post, but we managed to get some discussion out of it :joy:

Deithrian

Deithrian

I’m not sure I like macros either after trying to conditionally call a plug :confused:

OvermindDL1

OvermindDL1

Indeed long argument functions are painful, however a singular argument can be long in a set as well as it may not be a function but rather a macro thus the shape of the resultant AST needs to be kept intact.

Deithrian

Deithrian

In my personal and inexperienced opinion, a function with 30 arguments is Ebola.
Please don’t encourage/facilitate people to write such functions.

ryanwinchester

ryanwinchester OP

it’s arguably better if that single line of text has a lot of horizontal scrolling.

it’s the same idea with lists, and maps, etc.

sometimes you write them in a single line, and other times, you don;t

OvermindDL1

OvermindDL1

You are separating a sentence, basically a single ‘expression’, what this is talking about is when expressions-as-arguments are long enough that they no longer fit on one line, other-wise yes you would only use a single line. :wink:

It’s all exampled in this thread. :wink:

Yep yep, we need a Bikeshedding category/tag on these forums. ^.^

Then it’s not a perfect textual diff. ^.^

Qqwy

Qqwy

TypeCheck Core Team

To be honest, I wonder when git is smart enough to realize that when working with certain source code files, a line change that only adds a comma to the end is not that important. :stuck_out_tongue_winking_eye:

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews