Whitespace sensitivity

image

:upside_down_face:

It’s not required by any means, but it’s not disallowed by C# and somehow Unity adopted it as a convention in places. I could see a “readability” argument for the preference.

1 Like

I wonder if that webpage (not focused on coding style anyway) was made by someone not paying attention to coding style:

it’s funny they don’t even explicitly say “no space” for function call…


C also allows it, these language tends to “allow” simply because they don’t have a lot of syntax sugar and is filled with {} and ; so they are minimally sensitive to spacing of any kind, including linebreak

1 Like

That seems to be some random person who made a style guide?

In any case, they may have been changing to standard C# style. When I first used Unity years ago, it was spaces everywhere.

2 Likes

I see, in that case I will remember Unity as the first large community I know of that commonly uses func (x) style

1 Like

Classic Fortran is truly insensitive to whitespace, in a way no modern language is. Except for the reserved column rules, you can put blanks anywhere, even breaking up identifiers.

Here’s an example that prints squares of 1 through 10, with a little round-off error:

       P ROG RAM SQUARE S
       D O 10 0 IF 10 0=1 , 1 0
       PR INT *, E X P  (L O G (R EA L(IF10 0) )*2)
1 00   C ON TIN UE
       EN D PROGR AM SQUARES

Compiles just fine at Online Fortran Compiler - online editor . Set extra flags to -ffixed-form.

9 Likes

Awesome, I didn’t know this was even possible.

Here is an example from Intel OneAPI 2022 for people who think whitespace is so bad. Freedom and clarity are much appreciated. Again, I’m not recommending any styles, just repeating my first statement that disallowing whitespace was a bit extreme. I was punished by this error once in 2014, IIRC. Thank you all for expressing your opinions, I tried to express my idea far from personal preferences (I actually don’t prefer this whitespace most of the time), but I don’t like the idea of disallowing this either, for practical reasons. I know this discussion is not going anywhere and may stop at this point. Thank you everybody.

1 Like

All of Tim Davis’ C code (SuiteSparse, CHOLMOD, GraphBLAS) uses this style. I think it does actually help readability there. But since I read most Julia code in-editor bracket highlighting works perfectly.

1 Like