-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Keep spaces for named arguments #2038
Conversation
Hello @Viridovics, thank you for this first contribution to Fantomas. There are a few things though, which you could not have known:
SomeFunction(
name=
SearchForName(
"foooooooooooooooooooooooooooooooooooooooooooooooooo",
"baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"
)
) It just looks like
{ name =
SearchForName(
"foooooooooooooooooooooooooooooooooooooooooooooooooo",
"baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"
) }
let examineData x =
match data with
| OnePartData(part1=p1) -> p1
| TwoPartData(part1=p1; part2=p2) -> p1 + p2 Excuses for all these open questions, I wholeheartedly understand this is might not feel like a welcoming experience for your first PR. Changing the style is just a very delicate course of action in Fantomas. Once this is merged, in my experience someone will challenge this greatly and be annoyed that the style changed again. @dsyme, @Smaug123 and @kojo12228 could you respond to my questions above? Many thanks! PS: @dsyme, out of interest, would there be any room to have a special named argument expression node in the AST? |
The GR style guide says "Named arguments should also not have space surrounding the |
Yeah, we don't have a strong opinion and will align with Microsoft, whatever you decide. |
Alright, thanks for confirming. |
Hello @nojaf ! Thank you for detailed review! Created list needed fixes:
|
Hi @Viridovics, thanks for the additional changes for SynPat.
We don't really have a consensus on this yet. I mentioned that I found the absence of a space weird in the multiline assignment but that doesn't mean we need to go with it. I would really like to hear @dsyme his thoughts on this. In a perfect world, all of the stylistic debate would already have been done at fsharp/fslang-design. But as I mentioned, I recall some doubt on the topic. |
The current style guide says "no spaces", and all the code I personally write by hand has "no spaces" and so the current style guide reflects the visual expectations the language was originally designed for. However when I started using Fantomas more I found myself thinking this may have been a relic of an overly cramped, compact coding style. Looking at the samples in the tests I still find myself thinking this. @Smaug123 Do you really not have a strong preference? |
@dsyme Maybe a very mild personal preference for having more spaces, but it really doesn't arise much on the code I'm used to (which strongly prefers a single record containing config, rather than named arguments). |
@dsyme I find the no-space style too cramped and quite different from other similar places in the language where we do have spaces: we either have spaces on the both sides (binary operator expressions, tuple types, bindings, etc), or a space after the separator (tuple expressions and patterns, parameters, typed expressions), so I always put spaces for named arguments and patterns, and it looks kind of more inline with the rest of the language to me (but maybe it requires some getting used to). Maybe we could have a setting here? At least, if we don't change the default to have spaces 😅 |
I honestly think we should keep the space as it will be more consistent with the rest of the language. match x with
| SynExpr.TryFinally (trivia={ TryKeyword = mTry }) -> mTry It is weird to explain to a newcomer, that there should be no space for |
1a03294
to
388c8e2
Compare
Completely agree with this. |
OK, given the collected feedback we will keep the spaces. Can someone submit a PR to change the style guide please? Thanks |
Yes, I can pick this up later this week. @Viridovics I'm sorry this might have been an anticlimatic outcome for you. If you were rooting to remove the space in Fantomas, I understand this can be very frustrating. I still think your changes are an improvement in Thank you for understanding and thank you for your patience |
Hello @nojaf ! I've changed destination branch to master. Should I change anything else in this PR? Thank you. |
Hi @Viridovics! Well, given the outcome of this discussion, the space should be present again. |
Oh, and you might want to rebase again the latest master. |
Merge with master
Hi @Viridovics, I'm sorry for this next request but as the style guide was updated, the normal flow of Fantomas will actually already lead to the desired outcome. |
Hi @nojaf, no problem. I've reverted CodePrinter.fs. Keeped only new unit tests. |
* delete spaces for named arguments * restore space for multiline function argument * delete spaces for PatWithIdent * fix build * restore spaces * revert changes for CodePrinter.fs Co-authored-by: Florian Verdonck <[email protected]>
Fixes #1877