Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It's weird, I normally go with four spaces in personal code, but in my recent Perl6 'apocryphal' SchemeInterpreter I switched over to two spaces and I'm surprised by how much I like it.

Then again, this is code that I'll likely be using as the basis for an pod file discussing how it works and what's changed since Perl 6, so horizontal space is precious.

All that said, I'll use whatever the prevailing style is at whatever site I'm working on. If there is no prevailing style then I'll work to get one established and will argue for my choices, but once consensus is reached I go with that. The one thing I will not stand for is tabs used for anything but 'basic' indentation. For instance, consider the following (not good style, but it's just here to illustrate a point) code:

sub double_dispatch { my $self = shift; my $arg = shift; $arg->method($self, args => [@_]); }
If tabs are used for indentation then the 'actual characters' used would be as follows. Take '>>>>' to equal one tab.
sub double_dispatch { >>>>my $self = shift; >>>>my $arg = shift; >>>>$arg->method($self, >>>> args => [@_]); }
Using 'hard' tabs to do 'alignment' formatting is Bad And Wrong; it embeds your assumptions about tab width into the source file thus defeating the purpose of using tabs in the first place. Don't do it people.

I would be much more sanguine about tab indented code if people stuck to this rule, but unfortunately, they don't. Even more depressingly, the likes of emacs's otherwise wonderful cperl-mode doesn't make the distinction either. So for now, I argue for 'indents shall be a fixed number of spaces per level'. All things being equal, I choose four.

Yes, your assumptions are embedded in the source this way, but at least your careful formatting doesn't get fscked over when someone chooses a different tab width to view it with.

In reply to Re: Re: The One True Style of indentation: by pdcawley
in thread The One True Style of indentation: by Petruchio

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (3)
    As of 2018-01-20 02:18 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (226 votes). Check out past polls.