in reply to Re: How would you indent this?
in thread How would you indent this?

The problem with this is style is that the nether the braces nor the fields line up.

This is really bad.

We use indentation to identify where something starts and ends, but there's no } matching the row's {. It's ended up off by one.

We use indentation to indicate what is part of the same block, but name isn't at same level as key even though they're in the same block.

With both false positives and false negatives, this is an complete indentation failure.

And that's not even getting into the fact that it completely dropped the ball on offering the ability to spot differences between the lines at a glance when it could easily have done so.

Seeking work! You can reach me at ikegami@adaelis.com

Replies are listed 'Best First'.
Re^3: How would you indent this?
by parv (Vicar) on Mar 18, 2021 at 08:27 UTC

    In my own code I have given up on lining up either fields or the braces. As long as closing brace (or a key|field) is placed in a same column or after of opening brace (or previous key|field) (via indentation of expanding tabs), I am good.

    Anyone or anything (commit hook for example) else is more than free to mangle that to their own liking.

    I do not understand this part if you care to explain ...

    And that's not even getting into the fact that it completely dropped the ball on offering the ability to spot differences between the lines at a glance when it could easily have done so.
      > I do not understand this part if you care to explain ...

      This particular structure is semantically a table with one empty cell. He want's this table structure to be visible.

      I'm not aware of any Perl tool with the necessary heuristics to detect that table structure and to handle empty cells.

      At best Perl::Tidy with some obscure options, but not out-of-the-box

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      I do not understand this part if you care to explain ...

      The rows have different number of fields, but your choice of style doesn't make that stand out like some of the other options do.

      Seeking work! You can reach me at ikegami@adaelis.com

A reply falls below the community's threshold of quality. You may see it by logging in.