3

Is there a common style name/popular origin for the style of whitespace in code where you put spaces inside parentheses but not after keywords in control statements, or after function names? (See img)

This is my preferred whitespace method (in most languages), but I don't know where I adopted it from, if anywhere... ;P

Comments
  • 5
    Looks like someone strictly following the PSR, except for the additional white space for args.

    https://www.php-fig.org/psr/psr-2/
  • 5
    Well you are putting whitespace as far as you can 😆

    Try to add it after function name as well 😛
  • 5
    I see this style a lot when working with WordPress. I adopted it for a little while but got lazy and went back to no space inside of parentheses (not counting spaces after commas).
  • 6
    Why all of the excessive newlines?
    They absolutely detract from readability.

    Also: `if` is a keyword, not a function. Add a space between it and its condition. They aren't arguments!
  • 1
    Interior padding?
    While I don’t naturally do it I have been known to do it when things get “thick” to help readability in Linq or method definition/calls.
  • 1
    @Root subjective to personal preference. And this is actual php psr-2 standard compliant code.

    I agree about the space between the if statements. Without them it does make them look like functions
  • 2
    @Root I find it easier to read the flow of (and quickly scan) code when the curly braces are on their own line, and don't find it excessive at all. Imo, Allman style indenting/braces is far more readable than K&R. Whitespace is no longer a limited commodity - I don't print code on paper.

    However, "no space after 'if'" is the essence of my post; I've been doing it for close to 20 years, and I don't know where I picked it up from, but by now I cannot stop doing it because everything else looks broken :/
  • 2
    @iamavalos so that’s what mess my linter tried pulling earlier.

    Yea no thanks.
  • 0
    Another sample of my whitespace madness:
  • 2
    @wizzzard My coding style could be summarized as the exact opposite of everything you do. (Except spaces within parentheses)
  • 1
    That's what I love about Go language. Just one universal formatting style for everyone. No customization options nothing.
    Not every freaking project has its own formatting style, everyone has to follow the one single style. Makes it much easier to read other people's code when everyone follows the same formatting.
  • 1
    I’m so used to not having this kind of padding that it actually makes it less readable to me
  • 3
    I’ve really never understood why you need all that extra white space though.

    This for example, still covers all that but is quicker to read over and know what’s going on, plus extra padding in args drives me crazy 😂

    *this is not my normal editor, but you can only do so much on an iPhone 😔
  • 2
    @gaaraDev common placeholders for example code, have no actual use.
  • 1
  • 2
    I have a thing for hand-minified Javascript code.. You probably don't want to see that..
Add Comment