You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use blank-lines to separate different multi-line blocks.
Use line breaks between control flow statements and returns.
i wasn't sure how to translate the first one into a rule for a Formatter to follow, unless it just mean "have a blank line after end". If it can be translated to that, then the second one is just a special-case (assuming "control flow" here means only while.. end and if... end statements, which it seems to be, based on the example given).
I suggest we simplify these two rules in one. Below are some options for the new rule:
Option 1:
Add a blank line after end in multi-line blocks
# Yes:if foo
println("Hi")
endfor i in1:10println(i)
end# No:if foo
println("Hi")
endfor i in1:10println(i)
end
# Yes:functionfoo(bar; verbose=false)
if verbose
println("baz")
endreturn bar
end# No:functionfoo(bar; verbose=false)
if verbose
println("baz")
endreturn bar
end
Note that in this second example, the No case is currently listed as OK.
Option 2
Add a blank line between multiple multi-line blocks
# Yes:if foo
println("Hi")
endfor i in1:10println(i)
end# No:if foo
println("Hi")
endfor i in1:10println(i)
end
Note we now longer give an opinion on the second example above (the blank line after end / before return)
Option 3
Stop giving guidance on this
For what it is worth, i'd happily go with Option 3. In practice, i'm happy enough writing code that follows Option 2, but Option 1 seems a little too fussy to me.
The text was updated successfully, but these errors were encountered:
Noticed when writing up domluna/JuliaFormatter.jl#283 (see domluna/JuliaFormatter.jl#283 (comment), related to #7), but better to discuss here :)
We currently have two rules:
i wasn't sure how to translate the first one into a rule for a Formatter to follow, unless it just mean "have a blank line after
end
". If it can be translated to that, then the second one is just a special-case (assuming "control flow" here means only while.. end and if... end statements, which it seems to be, based on the example given).I suggest we simplify these two rules in one. Below are some options for the new rule:
Option 1:
end
in multi-line blocksNo
case is currently listed asOK
.Option 2
end
/ beforereturn
)Option 3
For what it is worth, i'd happily go with Option 3. In practice, i'm happy enough writing code that follows Option 2, but Option 1 seems a little too fussy to me.
The text was updated successfully, but these errors were encountered: