I have some stylistic preferences listed below. I am wondering which I can keep using, and which I should change to conform to the community.
- I used the “Format Document” option in VSCode, and it made some choices that I don’t think read very well. I read through the style guide. These topics aren’t specifically addressed, but it does seem to encourage spaces between binary operators and discourage extra parentheses. Is the VSCode format the preferred way, or are one of the other options below acceptable?
# Auto-formatted for n in 2:N - 1 # It looks like the subtraction is applied to every element of the range. push!(v, v[end] + x - 1) # Hard to see that the last terms all combine into one argument. end
# Parentheses for n in 2:(N - 1) push!(v, (v[end] + x - 1)) end
# No spaces (my preference) for n in 2:N-1 push!(v, v[end]+x-1) end
# Extra spaces for n in 2 : N - 1 push!(v, v[end] + x - 1) end
Additionally, I quite like the naming scheme
for i in 1:I. However, I know Fortran users hate to see that. I also realize it is against the style guide which says that variable names should be lower case. Is there a Julian convention for naming the length of a dimension?
Lastly, I like to group longer mathematical expressions by term like
z = w + x*(y - 1) - 3*z, but the automatically formatted style would be
z = w + x * (y - 1) - 3 * zinstead.