-
Notifications
You must be signed in to change notification settings - Fork 4
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
ambiguous linebreaking of assignments (question) #98
Comments
as a note, the "line-breaked" form indentation looks particularly sub-optimal in cases; e.g. here: line_system =
:point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
) (taken from ConstraintTrees.jl) |
another example (again taken plain from ConstraintTrees:) Base.:+(a::LinearValue, b::LinearValue) =
let
(idxs, weights) =
add_sparse_linear_combination(a.idxs, a.weights, b.idxs, b.weights)
LinearValue(; idxs, weights)
end
#vs.
Base.:+(a::LinearValue, b::LinearValue) = let
(idxs, weights) = add_sparse_linear_combination(a.idxs, a.weights, b.idxs, b.weights)
LinearValue(; idxs, weights)
end |
Hi, in general Runic doesn't modify newlines in the source. So for example, if you have put a line break after
Yea but doesn't it almost always look better with no newline after the line_system = :point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
)
This would again look better as |
@fredrikekre ah I see, thanks for the explanation. Just a few notes about the examples: line_system =
:point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
) this is mildly confusing because the "point", "x" and "y" look like the same-level kind of thing, because they "share the indent" Re the second example, full agree that it would be better with The property with retained linebreaks explains it, this issue is then effectively not an issue, so closing. Thanks again! :) |
I agree, it is tricky. This is related to the "hard" vs "soft" indenting discussed in https://github.com/fredrikekre/Runic.jl/blob/master/README.md#indentation. Going with just "hard" indent would do line_system =
:point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
) becuase the line_system = :point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
) so this is also a bit inconsistent. |
Yeah, the hard indent might be too much. The "slightly inconsistent" is mildly inconsistent w.r.t. AST (depending on how you define consistency) but at least consistent w.r.t. user-visible brackets (parentheses in this case). Just to be complete about the design space, this is a possible middle ground taken by many formatters: line_system = :point^C.ConstraintTree(
:x => C.Constraint(0 + 2 * line_param),
:y => C.Constraint(0 + 1 * line_param),
) |
Yea, I don't mind that formatting, just isn't how most existing (Julia) code look like. For example, if I have code like this: push!(
x,
1,
2
) and then later want to assign the result of this call and adding |
Hello!
is Runic formatting output supposed to depend on changes of blank characters in the input?
In particular I found a few spots where Runic accepts two different line-breakings as "OK" and doesn't change them (i.e., does not enforce the unique formatting), no matter that they are equivalent as source code:
Is this intended? If it is, is there be some way (option perhaps) to enforce a completely blanks-insensitive formatting?
Thanks!
-mk
cc @stelmo
The text was updated successfully, but these errors were encountered: