http://qs321.pair.com?node_id=11129887


in reply to How would you indent this?

Since you asked for it ...

# vim : tabstop=3 shiftwidth=3 softtabstop=3 shiftround textwidth=90 a +utoindent expandtab my @headings = ( { key => 'k', name => 'Kanji', class => 'kanji' }, { key => 'skip', name => 'SKIP', class => 'skip-code' }, { key => 'co', name => 'Suggestion', class => 'skip-code' }, { key => 'disc', name => 'Discussion' } );

Replies are listed 'Best First'.
Re^2: How would you indent this?
by ikegami (Patriarch) on Mar 18, 2021 at 07:42 UTC

    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

      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.