-
Notifications
You must be signed in to change notification settings - Fork 34
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
Relax opinion on use of ;
in NamedTuples?
#62
Comments
Existing guidance # Yes:
xy = (x=1, y=2)
x = (x=1,) # Trailing comma required for correctness.
x = (; kwargs...) # Semicolon required to splat correctly.
# No:
xy = (x = 1, y = 2)
xy = (;x=1,y=2)
x = (; x=1) Suggested change to # Yes:
xy = (; x=1, y=2)
x = (; x=1,)
x = (; kwargs...)
# Ok:
xy = (x=1, y=2)
# No:
xy = (x = 1, y = 2)
xy = (;x=1,y=2) |
My preference is to not use the semi-colon. You are correct in that the rule is more straight forward with always including the semi-colon but the only case it's required is for splatting so really we're just enforcing the use of two extra characters to gain a little extra consistency. Most people probably don't encounter |
IMO the no-semicolon version is somewhat unsafe due to how easy it is to forget a trailing comma on a single-element |
Current guidnace is "NamedTuples should not be prefixed with
;
at the start" (related to #22)As the current examples show this leads to these three cases having different style:
I can't help but feel that this is a simpler rule:
Also, I write a lot of code in codebases that follow BlueStyle and I don't recall anyone ever corrected me on adding/removing a
;
, so i wonder how much this guidance is even followed right now.(related to #7, domluna/JuliaFormatter.jl#283 (comment))
The text was updated successfully, but these errors were encountered: