Loop and argument spacing style

Note that there are various additional style guides (YASGuide, BlueStyle, …) and while they have a lot of overlap, there is no single community-wide style guide that addresses everything.

AFAIK the preferred approach is that package authors pick a style, and contributors just conform to that.

I do that when it makes sense, but occasionally deviate. Eg I would be tempted to write the above as

for n in 2:(N - 1)           # OR 2:(N-1) is fine too
    push!(v, v[end] + x - 1) # note: removed unnecessary ()s
end

removing superfluous ()s.

Well, tough luck, they are reading Julia code.

Not that I am aware of, if it is a vector then len is common, N is also fine.

Just do that then.

Generally, while style guides are useful, I would not get too hung up about these details. Just keep coding and occasionally prettify if you feel like it.

FWIW, IMO refactoring to improve code clarity is much more important for readability than tiny details about spaces and such.

2 Likes