-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 Trailing commas 🎉 #1775
🎉 Trailing commas 🎉 #1775
Conversation
For reference: #1549 |
@@ -116,13 +116,13 @@ let res = | |||
id( | |||
fun | |||
| Some(x) => x + 1 | |||
| None => 0 | |||
| None => 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this trailing comma expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a trailing comma on the function argument. I’m pretty sure this is what we want. The alternative is to not print trailing commas for functions accepting only one argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be a lot nicer to look at with different function
syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if fun
s had braces, it would be nicer. There was discussion about adding them. In the mean time, the comma is kind of nice in that it tells you pretty clearly where to add another argument. We could also special case it so that single argument functions whose argument is a fun |
do not print the trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the mean time, the comma is kind of nice in that it tells you pretty clearly where to add another argument
This seems like a compelling argument for keeping the trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It felt a bit odd when I saw it, but it makes sense.
I really like this change and I agree it helps with paren-fatigue 👍
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. |
"func": a => {"a": (arg1, arg2) => arg1 + arg2} | ||
"func": a => { | ||
"a": (arg1, arg2) => arg1 + arg2 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems missing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes JS objects were the only ones I didn’t get to. I’ll try to add them before landing.
Summary: Test Plan: Reviewers: CC:
Going to merge: Suggestions for anyone trying to extend this to other features in the future: |
Intelligent printing and parsing of trailing commas on basically everything!
Please see the stack of diffs here. Each commit accomplishes some purpose and it will be much easier to understand the entire set of changes by looking at the individual commits.