-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Function arguments in multiple lines. #17
Comments
One per line is insane to read when you get to like 30 keyword arguments. Closing parenthesis is fine on its own line though. @YingboMa what do you think? |
Given that a column width is being enforced, it shouldn’t be hard to see the closing parenthesis if it is on the same line as arguments. There is something to be said for saving vertical space too. |
It also (to my eyes), breaks the convention that the indentation can be quickly scanned to see where a function ends. Now one has to actively ignore parentheses that arise at the same indentation level (will editors handle that without issues when one uses code folding?). |
Code folding is indeed a bit strange when the closing parenthesis is not indented. You get two folds: One for the args and another for the function body. But maybe that can be solved on the VS Code Julia Extension? julia-vscode/julia-vscode#2907 |
That doesn’t seem too bad! But there are many different editors people use, and I’d worry a decent number of them may have issues. |
Yeah, I agree. I made sure JuliaFormatter preserves function my_large_function(argument1, argument2,
argument3, argument4,
argument5, x, y, z)
...
end |
@YingboMa Is it guaranteed to preserve:
too? |
Just my 2 cents. Here I think BlueStyle version is better, especially when you have a lot of keywords with large names. Take a look at this snippet from PrettyTables.jl with BlueStyle and SciMLStyle: pinfo = _print_info(
data;
alignment = alignment,
cell_alignment = cell_alignment,
cell_first_line_only = cell_first_line_only,
compact_printing = compact_printing,
formatters = formatters,
header = header,
header_alignment = header_alignment,
header_cell_alignment = header_cell_alignment,
max_num_of_columns = max_num_of_columns,
max_num_of_rows = max_num_of_rows,
limit_printing = limit_printing,
renderer = renderer,
row_labels = row_labels,
row_label_alignment = row_label_alignment,
row_label_column_title = row_label_column_title,
row_number_alignment = row_number_alignment,
row_number_column_title = row_number_column_title,
show_header = show_header,
show_row_number = show_row_number,
show_subheader = show_subheader,
title = title,
title_alignment = title_alignment
)
pinfo = _print_info(data; alignment = alignment,cell_alignment = cell_alignment,
cell_first_line_only = cell_first_line_only,
compact_printing = compact_printing, formatters = formatters,
header = header, header_alignment = header_alignment,
header_cell_alignment = header_cell_alignment,
max_num_of_columns = max_num_of_columns,
max_num_of_rows = max_num_of_rows, limit_printing = limit_printing,
renderer = renderer, row_labels = row_labels,
row_label_alignment = row_label_alignment,
row_label_column_title = row_label_column_title,
row_number_alignment = row_number_alignment,
row_number_column_title = row_number_column_title,
show_header = show_header, show_row_number = show_row_number,
show_subheader = show_subheader, title = title,
title_alignment = title_alignment) IMHO is way easier to work with the first version to fix problems or update something. |
The counterpoint is that the blue style uses a lot more vertical screen space, thereby increasing the chance of being unable to fit all the code in a function on a single screen (especially on laptop screens). I find that a lot more of an obstacle than having multiple parameters per line. |
Any reason not to prefer the Blue style advice here:
Notably, when there are many arguments in multiple lines, no argument is placed on the same line as the function name.
All arguments are at the same, one-level, indentation, so there is no custom indentation here and there are no alignment issues if, say, the function name changes.
Also, the closing parenthesis is alone in its own line, making very clear when the argument list stops and the code begins.
However it'd be fine that not every argument is on its own line (as enforced by Blue, but relaxed here).
The text was updated successfully, but these errors were encountered: